【发布时间】:2013-01-30 01:04:55
【问题描述】:
我有一个 csv 文件,每行有 5 个条目。每个条目都是网络数据包是否被触发。每行的最后一项是数据包的大小。每行 = 以毫秒为单位的时间。
例如行
1 , 0 , 1 , 2 , 117
如何绘制图表,例如其中 x 轴是行号,y 是例如的值每行的第一个条目?
【问题讨论】:
我有一个 csv 文件,每行有 5 个条目。每个条目都是网络数据包是否被触发。每行的最后一项是数据包的大小。每行 = 以毫秒为单位的时间。
例如行
1 , 0 , 1 , 2 , 117
如何绘制图表,例如其中 x 轴是行号,y 是例如的值每行的第一个条目?
【问题讨论】:
这应该让你开始:
set datafile separator ","
plot 'infile' using 0:1
【讨论】:
"," 和comma 之间是否有任何细微差别。
src/set.c:2386 读作df_separator = ','; 和src/set.c:2392 读作df_separator = sep[0]; 在我看来应该是一样的。
src/ 中搜索"comma" 找到了上述行:)。
您还可以使用 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 '<Fromfile.csv>' with line lt -1 lw 2
更多线条编辑选项(破折号和线条颜色等)位于: http://gnuplot.sourceforge.net/demo_canvas/dashcolor.html
apt-get install gnuplot)brew install gnuplot)【讨论】: