我有一个csv文件,每行有5个条目。每个条目都表示是否触发了网络数据包。每行的最后一个条目是数据包的大小。每行表示消耗的时间(毫秒)。
例如,一行如下:
1 , 0 , 1 , 2 , 117
我该如何绘制一个图表,例如X轴是行号,Y轴是每行的第一个值?
set datafile separator ","
plot 'infile' using 0:1
您也可以使用免费的gnuplot将内容绘制到png文件中:
终端命令
gnuplot> set title '<title>'
gnuplot> set ylabel '<yLabel>'
gnuplot> set xlabel '<xLabel>'
gnuplot> set grid
gnuplot> set term png
gnuplot> set output '<Output file name>.png'
gnuplot> plot '<fromfile.csv>'
注意:在set output
中你总是需要提供正确的扩展名(这里是.png)。
如果你的数据不连续,那么输出的结果可能也不是线性的。要解决这个问题,只需将'plot'行更改为:
plot '<Fromfile.csv>' with line lt -1 lw 2
更多线条编辑选项(破折号和线条颜色等)请查看:http://gnuplot.sourceforge.net/demo_canvas/dashcolor.html
apt-get install gnuplot
)brew install gnuplot
)
","
和comma
之间是否有任何细微差别。 - mgilsonsrc/set.c:2386
读取df_separator = ',';
而src/set.c:2392
读取df_separator = sep[0];
在我看来应该是相同的。 - Thorsrc/
中使用 grep 查找"comma"
来找到上述行 :)。 - Thor