我正在尝试使用Gnuplot绘制TCP连接的带宽增长情况。
我有2个日志文件,一个文件一次具有带宽,另一个文件具有时间戳,在该时间戳下发生数据包丢失。我想用与带宽相同的图形表示数据包丢失,可能在X轴(时间)上有一条垂直线。
请提供建议!
就像一个非常粗糙的例子一样,以下是文件格式。
带宽数据
0.001 2
0.002 3
0.003 5
0.004 8
Packet_Drop.dat
0.006
0.12
0.39
所需地块:
抱歉,不知道如何快速制作出更好的图形!
作为一种选择,您可以使用impulses
绘制样式,该样式绘制从y = 0到给定值的垂直线:
max = 10
plot 'Bandwidth.dat' using 1:2 with lines linecolor rgb 'black',\
'Packet_Drop.dat' using 1:(max) with impulses linecolor rgb 'red'
使用此选项的缺点是,您必须知道y轴的最大值。您可以通过绘制到unknown
终端来获得此信息,然后使用GPVAL_Y_MAX
值:
set terminal push # save current terminal
set terminal unknown
plot 'Bandwidth.dat' using 2
set terminal pop # restore terminal
plot 'Bandwidth.dat' using 1:2 with lines linecolor rgb 'black',\
'Packet_Drop.dat' using 1:(GPVAL_Y_MAX) with impulses linecolor rgb 'red'
(不能stats
用来获取自动缩放轴的最大值。)
或者,您可以将数据文件中的x值读入字符串中,然后遍历单词并相应地设置一些箭头。在Linux上,使用
packet_drop = system('cat Packet_Drop.dat')
set for [w in packet_drop] arrow from first w, graph 0 to first w, graph 1 linecolor rgb 'red' nohead
plot 'Bandwidth.dat' using 1:2 with lines lc rgb 'black'
在Windows上,它应与
packet_drop = system('type Packet_Drop.dat')
并且wgnuplot_pipes.exe
在使用4.6版时需要使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句