一個ns-3的Gnuplot例子

一個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  //使用第一列與第三列的二分之一繪圖


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章