`columnhead(N)` 和 `columnheader(N)` 有什么区别?

What is the difference between `columnhead(N)` and `columnheader(N)`?

在 Gnuplot 5.2 中,您可以使用 plot "datafile" ... title columnheader(1) 将数据文件中第一个字符串显示为键。但是,当您尝试附加 plot "datafile" ... title columnheader(1) . "X" 中的字符串时,它会失败并显示 unexpected ot unrecognized token.

然而,当我使用 plot "datafile" ... title columnhead(1) . "X" 时,它起作用了!

那么columnheader(N)columnhead(N)有什么区别,为什么两者都存在?

另见

帮助文本试图对此进行解释。 columnhead(x) 是一个 string-valued 函数。因此,它可以与其他功能组合或组合。

gnuplot> help columnhead
 `columnhead(x)` may only be used as part of a plot, splot, or stats command.
 It evaluates to a string containing the content of column x in the first line
 of a data file. See `plot datafile using`.

请注意,此函数可以在 plot 命令中的任何位置使用,而不仅仅是作为标题选项。举个人为的例子:

plot DATA using 1:2:(columnhead(3)) with labels

相比之下,关键字 columnheader 仅作为标题选项有效。常见用途是作为 set key 命令的选项,形式为

set key autotitle columnheader

它会影响从数据文件生成的所有绘图组件(而不是函数)。为方便起见,它也可以作为单个绘图组件的标题替代,如

plot DAT1 using 1 title "foo", DAT2 using 2 title "baz", DAT3 using 3 title columnheader

这样做的一个缺点是程序必须猜测指的是哪一列。在上面的例子中是明确的,但考虑:

   plot DAT3 using (+)/() title columnheader  # _which_ columnheader?

因此,作为一种特殊情况,程序会查看括号中的特定列是否紧跟在关键字之后。 IE。它看起来像一个函数,但实际上不是。该程序可以更聪明,并意识到它可以使用实际函数 columnhead(),但不幸的是它并不那么聪明。