【问题标题】:gnuplot: for and columnheader commandgnuplot:for 和 columnheader 命令
【发布时间】:2014-10-19 08:29:32
【问题描述】:

我打算绘制多列数据文件。用第一列和第 i 列绘制 xy 图。所以命令的工作基于手册。哪个gnuplot版本开始有这样的功能?我的机器安装了version4.2,但是不能工作。 columnheader() 的相同问题
我想确定是我的代码问题还是版本问题。

【问题讨论】:

  • 我认为plot for ...从4.4开始可用,而更强大的do for [...] {...}从4.6开始可用。
  • @Miguel 我不一定会说do for 更强大,因为在这种情况下您必须使用plot for ;)

标签: for-loop gnuplot columnheader


【解决方案1】:

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

如果标题列与using 语句中给出的列不匹配,您也可以使用title columnheadertitle columnheader(i+1),而不是使用set key autotitle columnheader。这至少从 4.2 开始也有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多