如何将 gnuplot 公式放入变量中

How to put a gnuplot formula into a variable

我有一个 gnuplot 图,它有一些大公式和重复公式来计算一些 y 值。有点像这个:

plot 'data1.csv' using 1:(column('a') / column('b') / 1000) with linespoints title 'data 1',
'data2.csv' using 1:(column('a') / column('b') / 1000) with linespoints title 'data 2';

是否可以将公式移出到变量中? 也许是这样的(但不起作用):

y = (column('a') / column('b') / 1000)
plot 'data1.csv' using 1:y with linespoints title 'data 1',
'data2.csv' using 1:y with linespoints title 'data 2';

不是变量(标量),但可以定义函数:

  y(v1,v2) = column(v1) / column(v2) / 1000
  plot 'data1.csv' using 1:(y('a','b')) with linespoints title 'data 1'

在您的特定情况下,该函数不需要将实际的列标识符作为参数,因为它们是常量。因此可以使用一个虚拟参数的更简单的函数

  y(dummy) = column('a') / column('b') / 1000
  plot 'data1.csv' using 1:(y(0)) with linespoints title 'data 1'