Gnuplot 5.0 patchlevel 4 - 在宏中传递列号

时间:2016-09-01 10:13:42

标签: gnuplot

我有一个包含十几列的数据文件(见下文),我只对第一列中的值超过给定间隔时绘制两列(比如5和10)感兴趣。为此,我定义了:

inter(min,max,var,colx)=(min<=column(var)&&column(var)<=max?column(colx):NaN)

使用plot 'data.dat' u (inter(0.25,0.5,1,5)):10按预期工作,在第1列的[0.25:0.5]间隔值上绘制第5列和第10列。

由于我需要在不同的时间间隔内绘制各对列,我创建了一个文件PlotInterval.p,其中包含

inter(min,max,var,colx)=(min<=column(var)&&column(var)<=max?column(colx):NaN)
plot ARG1 u (inter(ARG2,ARG3,ARG4,ARG5)):ARG6

当我用call 'PlotInterval.p' 0.25 0.5 1 5 10调用它时,我收到错误消息:

gnuplot> call 'PlotInterval.p' 'data.dat' 0.25 0.5 1 5 10
     "PlotInterval.p", line 3: warning: no column with header "1"
     "PlotInterval.p", line 3: warning: partial match against column 6 header "1.451433e-005"
gnuplot> plot ARG1 u (inter(ARG2,ARG3,ARG4,ARG5)):ARG6
                                                  ^
     "PlotInterval.p", line 3: x range is invalid

列号未正确传递(间隔的最小值和最大值正确传递)。

以下是data.dat的第一行:

0.000000e+000   -1.577475e+000  -7.175042e+000  2.764545e-005   -5.966045e+000  1.451433e-005   -4.665347e+000  -1.412159e-005  6.154827e+000   0.000000e+000   0.000000e+000   3.100275e+002   0.000000e+000   
2.500000e-003   4.346526e+000   -1.305610e+001  3.170804e-005   -5.790276e+000  1.632860e-005   -4.574010e+000  -1.459951e-005  6.069773e+000   -1.521847e+000  -1.521847e+000  3.009973e+002   0.000000e+000   
5.000000e-003   1.055312e+001   -1.861278e+001  3.085889e-005   -5.604992e+000  1.797386e-005   -4.472427e+000  -1.651171e-005  5.977640e+000   -7.909049e+000  -7.909049e+000  3.029022e+002   0.000000e+000   
7.500000e-003   1.676089e+001   -2.476250e+001  3.417608e-005   -5.412398e+000  2.195262e-005   -4.354189e+000  -1.823193e-005  5.874751e+000   -4.333744e+000  -4.333744e+000  2.982168e+002   0.000000e+000   
1.000000e-002   2.276874e+001   -3.064776e+001  3.607515e-005   -5.204357e+000  2.585798e-005   -4.212604e+000  -1.948774e-005  5.763049e+000   -9.444781e+000  -9.444781e+000  2.864735e+002   0.000000e+000   
1.250000e-002   2.901897e+001   -3.670245e+001  3.681956e-005   -4.988488e+000  2.942617e-005   -4.048886e+000  -2.254946e-005  5.638561e+000   -1.512790e+001  -1.512790e+001  2.852074e+002   0.000000e+000   
1.500000e-002   3.479634e+001   -4.301166e+001  4.146322e-005   -4.756663e+000  3.338716e-005   -3.862872e+000  -2.427187e-005  5.499905e+000   -1.618025e+001  -1.618025e+001  2.797585e+002   0.000000e+000   
1.750000e-002   4.052957e+001   -4.899462e+001  4.416380e-005   -4.503088e+000  3.794105e-005   -3.651641e+000  -2.608256e-005  5.350786e+000   -2.219509e+001  -2.219509e+001  2.736614e+002   0.000000e+000   
2.000000e-002   4.657926e+001   -5.503798e+001  4.764674e-005   -4.231202e+000  4.255615e-005   -3.413258e+000  -2.911828e-005  5.187315e+000   -2.519971e+001  -2.519971e+001  2.689015e+002   0.000000e+000

我错过了什么吗?如何获取要传递的列号?有解决方法吗?非常感谢。

1 个答案:

答案 0 :(得分:0)

变量ARG1等是字符串变量,column对字符串或整数变量的工作方式不同。因此,您必须将给定column的值显式地转换为整数:

inter(min,max,var,colx)=(min<=column(int(var))&&column(int(var))<=max?column(int(colx)):NaN)
plot ARG1 u (inter(ARG2,ARG3,ARG4,ARG5)):ARG6