回到一个旧项目,显然已经忘记了一些事情。 数据文件:
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