我正在尝试使用Gnuplot绘制TCP连接的带宽增长。
我有2个日志文件,一个带有一次带宽,另一个带有发生数据包丢弃的时间戳。我想在与带宽相同的图表中表示数据包丢失,可能在X轴(时间)上有一条垂直线。
请提供建议!
就像一个非常粗略的例子,这里是文件格式。
Bandwidth.dat
0.001 2
0.002 3
0.003 5
0.004 8
Packet_Drop.dat
0.006
0.12
0.39
必填图:
抱歉,不知道如何快速制作更好的图表!
答案 0 :(得分:2)
作为一个选项,您可以使用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')
并且在使用版本4.6时需要使用wgnuplot_pipes.exe
。