64

我有一个 csv 文件,每行有 5 个条目。每个条目都是网络数据包是否被触发。每行的最后一项是数据包的大小。每行 = 经过的时间(以毫秒为单位)。

例如行

1 , 0 , 1 , 2 , 117

如何绘制图表,例如其中 x 轴是行号,y 是例如每行中第一个条目的值?

4

2 回答 2

90

这应该让你开始:

set datafile separator ","
plot 'infile' using 0:1
于 2013-02-14T09:16:48.537 回答
17

您还可以使用 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>'

注意:您始终需要在此处提供正确的扩展名(此处为 .png)set output

那么输出也可能不是行,因为您的数据没有继续。要解决此问题,只需将“情节”行更改为:

plot '<Fromfile.csv>' with line lt -1 lw 2

更多线条编辑选项(破折号和线条颜色等): http: //gnuplot.sourceforge.net/demo_canvas/dashcolor.html

  • gnuplot 在大多数 Linux 发行版中都可以通过包管理器使用(例如,在基于 apt 的发行版上,运行apt-get install gnuplot
  • gnuplot 可通过 Cygwin 在 Windows 中使用
  • gnuplot 在 macOS 上可以通过homebrew (run brew install gnuplot)获得
于 2014-05-04T21:17:45.997 回答