我有一个看起来像这样的数据文件
#index name1 name2 name3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
我想绘制 3 行:
plot "data" using 1:2 with lines,\
...
这工作正常,除了线标签。如何指定数据文件中的列名?
如果你有 gnuplot 4.2 或更新版本,你可以很容易地做到这一点。不过,您需要去掉第一行的注释标记。
使用这样的文件:
index name1 name2 name3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
以下将做你想要的:
set key autotitle columnheader
plot 'a.dat' u 1:2 w l, '' u 1:3 w l, '' u 1:4 w l
如果我set term dumb
在绘图之前这样做,我会得到一个很好的 ascii 图。我喜欢gnuplot!
7 ++----------+----------+-----------+-----------+----------+---------$$$
+ + + + + name1$****** +
| $name2 ###### |
| $$$$$$ name3 $$$$$$ |
6 ++ $$$$$$ ###
| $$$$$$ ###### |
| $$$$$$ ###### |
| $$$$$$ ###### |
5 ++ $$$$$ ###### ***
| $$$$$$ ###### ****** |
| $$$$$$ ###### ****** |
| $$$$$$ ###### ****** |
4 $$$ ##### ****** ++
| ###### ****** |
| ###### ****** |
| ###### ****** |
3 ### ***** ++
| ****** |
| ****** |
+ ****** + + + + + +
2 ***---------+----------+-----------+-----------+----------+----------++
1 1.5 2 2.5 3 3.5 4
列标题(n)
比 更详细/更灵活set key autotitle columnheader
:
plot 'my.dat' using 1:2 title columnheader(2), \
'' using 1:3 title columnheader(3)
在 Gnuplot 4.6、Ubuntu 15.10 上测试。