For loop gnuplot中具有循环结构的三元算子

For loop gnuplot中具有循环结构的三元算子,for-loop,gnuplot,ternary-operator,For Loop,Gnuplot,Ternary Operator,我正在gnuplot中尝试以下操作: y(i,x) = i*x plot for [i=1:10:1] i==1 ? y(i,x) lc rgb "red" title "retas": y(i,x) lc rgb "red" notitle 但它给出了以下错误: gnuplot> plot for [i=1:10:1] i==1 ? y(i,x) lc rgb "red" title 'retas' : y(i,x) lc rgb "red" notitle

我正在gnuplot中尝试以下操作:

y(i,x) = i*x
plot for [i=1:10:1] i==1 ? y(i,x) lc rgb "red" title "retas": y(i,x) lc rgb "red" notitle
但它给出了以下错误:

gnuplot> plot for [i=1:10:1] i==1 ? y(i,x) lc rgb "red" title 'retas' : y(i,x) lc rgb "red" notitle
                                           ^
         expecting ':'
添加括号也没用

我知道,我可以通过以下方式获得结果:

plot for [i=1:10:1] i==1 ? 1/0 : y(i,x) lc rgb "red" notitle, y(1,x) lc rgb "red" title "retas"

但是为什么第一个命令不起作用呢?

可以用三元运算符包装,只构造绘图命令的一些独立部分:

y(i,x) = i*x
plot for [i=1:10:1] (i==1 ? y(i,x) : alt(i, x)) lc rgb "red" title (i == 1 ? "retas" : "")

是的,这很有效!对于[i=1:10:1]y(i,x)lc rgb“红色”标题(i==1?“retas:”),它可以更好地
绘图。我更正的代码上有一个打印错误:没有
alt(I,x)
。。。