ns3--Making Plots using the Gnuplot Class
来源:互联网 发布:编程麻将机 编辑:程序博客网 时间:2024/06/06 02:01
原文链接:
https://www.nsnam.org/docs/manual/html/gnuplot.html
was created using the following code from gnuplot-example.cc:
using namespace std;string fileNameWithNoExtension = "plot-2d";string graphicsFileName = fileNameWithNoExtension + ".png";string plotFileName = fileNameWithNoExtension + ".plt";string plotTitle = "2-D Plot";string dataTitle = "2-D Data";// Instantiate the plot and set its title.Gnuplot plot (graphicsFileName);plot.SetTitle (plotTitle);// Make the graphics file, which the plot file will create when it// is used with Gnuplot, be a PNG file.plot.SetTerminal ("png");// Set the labels for each axis.plot.SetLegend ("X Values", "Y Values");// Set the range for the x axis.plot.AppendExtra ("set xrange [-6:+6]");// Instantiate the dataset, set its title, and make the points be// plotted along with connecting lines.Gnuplot2dDataset dataset;dataset.SetTitle (dataTitle);dataset.SetStyle (Gnuplot2dDataset::LINES_POINTS);double x;double y;// Create the 2-D dataset.for (x = -5.0; x <= +5.0; x += 1.0) { // Calculate the 2-D curve // // 2 // y = x . // y = x * x; // Add this point. dataset.Add (x, y); }// Add the dataset to the plot.plot.AddDataset (dataset);// Open the plot file.ofstream plotFile (plotFileName.c_str());// Write the plot file.plot.GenerateOutput (plotFile);// Close the plot file.plotFile.close ();
示例代码: src/stats/examples/gnuplot-example.cc
会产生这些文件:
plot-2d.plt
plot-2d-with-error-bars.plt
plot-3d.plt
要处理这些文件,则:
$ gnuplot plot-2d.plt$ gnuplot plot-2d-with-error-bars.plt$ gnuplot plot-3d.pt
会产生这些图像文件:
plot-2d.png
plot-2d-with-error-bars.png
plot-3d.png
——————————分割线 9.8, 2016————————-
上次只是从官网上看了下怎么在.cpp文件里写跟gnuplot相关的代码。这次实际演练了一下。用官方提供了示例文件。 ns-3-allinone/ns-3-dev/examples/tutorial/fifh.cc
我在命令行里的过程如下。
在/home/cqq/repos/ns-3-allinone/ns-3-dev
目录下运行:
$ ./waf --run fifth > cwnd.dat 2>&1
这样就将运行fifth.cc
之后的结果重定向到cwnd.dat里面了,然后接下来,用gnuplot
的交互式环境来生成.png图片文件。
gnuplot> set terminal png size 640,480 gnuplot> set output "condo.png"gnuplot> plot "cwnd.dat" using 1:2 title 'Congestion Window' with linespointsgnuplot> exit
然后就可以发现目录下已经有了一个cwnd.png
图片文件了。
最后将mininet
系统里的cwnd.png
复制到宿主机OSX上查看图片。
0 0
- ns3--Making Plots using the Gnuplot Class
- Using the Debug Class
- Using the UIComponent class
- Using the StringBuilder Class
- Using the FlexPrintJob class
- WVPlots: example plots in R using ggplot2
- Making raw web service calls with the HttpWebRequest class
- Making And Using Library
- Making cloud using Houdini
- 2: Making & Using Objects
- C# Tutorial - Using the BackgroundWorker Class
- Using the True License ObfuscatedString class
- about using gnuplot
- Ubuntu中利用GNUPLOT画NS3产生的数据
- using ViewPager making a flush
- Making the Grade(poj1527)
- POJ3666---Making the Grade
- Making the Grade
- android 网络请求
- SQLL基础知识记录
- 南阳理工OJ 题目42 一笔画问题
- 如何用easyUI做Oracle的分页
- HDU 2066 一个人的旅行(Dijkstra算法)
- ns3--Making Plots using the Gnuplot Class
- Centos下无法格式化硬盘/dev/sd* is apparently in use by the system; will not make a filesystem here!
- PowerShell由进程名获取PID
- nginx配置location总结及rewrite规则写法(转发)
- Redis字符串类型的操作(二)
- decodeURIComponent()
- shell 杀死指定进程名称的进程方法
- 2017年搜狐内推 面试题——谈谈面试中的算法
- ubuntu下配置git和github初体验