gnuplot: for和columnheader命令

7

我打算绘制多列数据文件,使用第一列和第i列绘制xy图。因此,命令需要根据手册来工作。哪个gnuplot版本开始有这样的功能?我的机器安装了4.2版本,但不能使用。对于columnheader()也有相同的问题。
我想确定这是我的代码问题还是版本问题。


我认为自从4.4版本以后,plot for... 就已经可用了,而do for [...] {...}则更加强大,是在4.6版本中才被引入的。 - Miguel
@Miguel,我不会说do for更强大,因为在这种情况下你必须使用plot for ;) - Christoph
1个回答

17

版本4.2已经拥有了columnheader函数。

考虑数据文件data.txt,该文件包含:

first second third fourth
1 2 3 4
2 3 4 5
3 4 5 6

在gnuplot 4.2中,您可以使用例如:
set key autotitle columnheader
set style data lines
plot 'data.txt' using 1:2, '' using 1:3, '' using 1:4

从版本4.4开始,您可以在plot命令内使用迭代:

set key autotitle columnheader
set style data lines
plot for [i=2:4] 'data.txt' using 1:i

使用 set key autotitle columnheader 可以更改图例的标题。如果标题列与 using 语句中给定的列不匹配,可以使用 title columnheadertitle columnheader(i+1)。 这至少适用于4.2版本。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接