GNUplot:三元运算符中的字符串值

时间:2017-04-02 13:19:52

标签: gnuplot

回到一个旧项目,显然已经忘记了一些事情。 数据文件:

2017-03-31 14:38   6.42 feet  High Tide
2017-03-31 20:40   -0.30 feet  Low Tide
2017-04-01 02:56   6.92 feet  High Tide
2017-04-01 06:34   Full Moon
2017-04-01 09:19  -0.58 feet  Low Tide
2017-04-01 15:33   6.17 feet  High Tide

当我绘制如下图时,除了三元运算符以外,所有工作都正常,以测试strcol(3)中的字符串:

set terminal aqua size 950,594
set timefmt "%Y-%m-%d %H:%M"
unset key
set samples 1000
set xtics 86400
set x2tics 86400
set xtics nomirror font "Gill Sans Light,14" tc rgb "blue"
set grid ytics back
set grid x2tics
set format x "%a" 
set format x2 "%d" 
set xdata time
set x2data time
set yrange [-1:7.5]
set xzeroaxis lt 1 lw 1 lc rgb "red"
myDate(col1,col2)=sprintf("%s %s",strcol(1),strcol(2))
myLabel(col3,col2) = sprintf("%s ft.\n%s",strcol(col3),strcol(col2))
plot "tidefiles-test2.txt" \
u (myDate(1,2)):3:((strcol(5) eq "High") ? (myLabel(3,2)) :1/0) with labels font "Gill Sans Light,12" offset 0,-2  tc rgb "blue",\
"" u (myDate(1,2)):3:((strcol(5) eq "Low") ? (myLabel(3,2)) :1/0) with labels font "Gill Sans Light,12" offset 0,+2  tc rgb "red",\
"" u (myDate(1,2)):3:(strcol(3) eq "Full") ?  ("●"):1/0 w labels left font "Symbola,48" offset -4,0,\
"" u (myDate(1,2)):3 lc rgb "green" lw 1  sm cspl notitle

1 个答案:

答案 0 :(得分:1)

字符串for i in json_obj: token = i['access_token'] order_details = i['order_details'] 的行没有y值。因此,当满足条件Full时,实际的y值不是有效数字,因此也会跳过该点。

使用例如

strcol(3) eq "Full"

工作正常,但要求您使用硬编码的y值。否则,您必须在数据文件中为" Full" -case添加适当的y值。

enter image description here