一个ns-3的Gnuplot例子


http://blog.csdn.net/barcodegun/article/details/6899729


一个ns-3的Gnuplot例子

在安装目录下, /examples/tutorial目录下,有一个拥塞窗口的例子 fifth.cc,
可以执行:
$ ./waf --run examples/tutorial/fifth  >fifth.dat 2>&1
将会在安装目录下,生成 fifth.dat文件
解释:
> 表示输出重定向。
>fifth.dat  把执行的结果存入到文件。一般情况下,输出重定向到当前屏幕,>fifth.dat表示输出重定向到该文件。
2>&1 在shell中,文件描述符通常是:STDIN,STDOUT,STDERR,即:0,1,2,
&表示在后台执行, 2>&1 表示,把错误信息stderr也放到stdout中输出.


进入gnuplot:
$gnuplot
gnuplot>set terminal png size 640,480
gnuplot>set output "fifth.png"
gnuplot>plot "fifth.dat" using 1:2 title "Congestion Window" with linespoints
gnuplot>exit

在安装目录下,将会生成一个 fifth.png的图像。


解释:
set termianl  png   //设置输出图片格式,如png,gif,jpg等
set size  width,height  //设备图片宽度,高度
set output "图片名称"  //设置保存图片名称。


plot  title  "标题名"   //设置图片标题名称,一般用英文,有时不支持中文字符
plot "数据.dat"  using 1:2 with linespoints   //把数据文件"数据.dat"输出图像, using 1:2,使用第1,2列数据输出.
with linespoints //点用符号,点与点之间用线连接

a   plot "数据.dat"     //只输出数据点
b   plot "数据.dat" with lines   //把点连起来,成线。
c   plot "数据.dat" with linespoints  //点用符号,点与点之间用线连接
d   plot 'file.dat' using 1:3 with linespoints   //使用1,3列绘图
e   plot 'file.dat' using 1:($3/2) with linespoints  //使用第一列与第三列的二分之一绘图

posted @ 2016-05-16 23:07  张同光  阅读(126)  评论(0编辑  收藏  举报