我试图使用gnuplot绘制图形.我有6个文本文件.每个文本文件包含两列.第一列表示以秒为单位的时间(它是一个浮点数).Second是一个序列号.我想绘制所有六个文件的单个图表中的时间与序列号的关系图.我正在使用此文件来执行此操作.
set terminal png
set output 'akamai.png'
set xdata time
set timefmt "%S"
set xlabel "time"
set autoscale
set ylabel "highest seq number"
set format y "%s"
set title "seq number over time"
set key reverse Left outside
set grid
set style data linespoints
plot "print_1012720" using 1:2 title "Flow 1", \
plot "print_1058167" using 1:2 title "Flow 2", \
plot "print_193548" using 1:2 title "Flow 3", \
plot "print_401125" using 1:2 title "Flow 4", \
plot "print_401275" using 1:2 title "Flow 5", \
plot "print_401276" using 1:2 title "Flow 6"
Run Code Online (Sandbox Code Playgroud)
我的文件在哪里:
print_1012720 print_1058167 print_193548 print_401125 print_401275 print_401276它给出了一个奇怪的错误如下:
"plot.plt",第24行:未定义变量:plot
我做错了.是否可以在同一图表中绘制来自不同文件的输入数据.
mgi*_*son 124
你真是太近了!
更改:
plot "print_1012720" using 1:2 title "Flow 1", \
plot "print_1058167" using 1:2 title "Flow 2", \
plot "print_193548" using 1:2 title "Flow 3", \
plot "print_401125" using 1:2 title "Flow 4", \
plot "print_401275" using 1:2 title "Flow 5", \
plot "print_401276" using 1:2 title "Flow 6"
Run Code Online (Sandbox Code Playgroud)
至:
plot "print_1012720" using 1:2 title "Flow 1", \
"print_1058167" using 1:2 title "Flow 2", \
"print_193548" using 1:2 title "Flow 3", \
"print_401125" using 1:2 title "Flow 4", \
"print_401275" using 1:2 title "Flow 5", \
"print_401276" using 1:2 title "Flow 6"
Run Code Online (Sandbox Code Playgroud)
错误是因为gnuplot试图将"plot"这个词解释为要绘制的文件名,但是你还没有将任何字符串分配给名为"plot"的变量(这很好 - 这将是非常令人困惑的).
Ric*_*ard 66
如果您适当调整文件名或图表标题,您可能会发现gnuplot的for循环在这种情况下很有用.
例如
filenames = "first second third fourth fifth"
plot for [file in filenames] file."dat" using 1:2 with lines
Run Code Online (Sandbox Code Playgroud)
和
filename(n) = sprintf("file_%d", n)
plot for [i=1:10] filename(i) using 1:2 with lines
Run Code Online (Sandbox Code Playgroud)
Cir*_*四事件 18
replot是另一种获取多个图的方法:
plot file1.data
replot file2.data
Run Code Online (Sandbox Code Playgroud)