gnuplot:从数据中的字符串中提取 x 值

gnuplot: extract x-values from string in data

我的数据文件是这样的:

c0e0100.dat 0.234
c0e0200.dat 0.857
...
c0e1200.dat 0.003

我想从第一列文件名的第 4 到第 7 个字符中提取 x 值。 我尝试了以下用户功能:

str2num(s)=(s[4:7]+0.0)

然后:

plot 'file' using (str2num()):()

但这给出了:

internal error: substring range operator applied to non-STRING type

我也试过:

plot 'file' using (str2num(stringcolumn())):()

但得到了相同的结果。

有没有一种方法可以在 gnuplot 中做到这一点,而无需先 运行 通过外部工具获取数据?

表达式 </code> 是 <code>column(1) 的快捷方式,因此使用 </code> 已经为您提供了相应列的数字表示。要获取字符串值,请使用 <code>stringcolumn(1)(没有 $!),或 strcol(1):

str2num(s)=(s[4:7]+0.0)
plot 'file ' using (str2num(strcol(1))):2