Gnuplot,条件矢量风格给出错误

时间:2013-12-10 20:10:12

标签: conditional gnuplot

我是新来的,与Gnuplot有点关系。

我有下一个数据,一个逗号分隔的文本文件;

1386708463,830
1386708473,830
1386708484,830
1386708497,-830
1386708508,-830
1386708518,-840
1386708528,-840
1386708538,-840
1386708686,-950
1386708696,-960
1386708706,-960
1386708716,-940
1386708726,-940

当collumn 2中的值为负时,颜色必须为红色,否则为绿色。

我试过了;

plot "< tail -10 meterstanden.txt" using (-100):1:2:0 title "", \
     "< tail -11 meterstanden.txt" using (0):1:($2>0 ? $2:0/0):(0) title "Watt/uur " with vectors arrowstyle 2, \
     "< tail -11 meterstanden.txt" using (0):1:($2<=0 ? $2:0/0):(0) title "Watt/uur " with vectors arrowstyle 1, \
     "< tail -11 meterstanden.txt" using 2:1:2 with labels font "arial, 8"  offset 1.5,0.4

但是我得到了错误;

plot "< tail -10 meterstanden.txt" using (-100):1:2:0 title "",      "< tail -11 meterstanden.txt" using (0):1:($2>0 ? $2:0/0):(0) title "Watt/uur " with vectors arrowstyle 2,    "< tail -11 meterstanden.txt" using (0):1:($2<=0 ? $2:0/0):(0) title "Watt/uur " with vectors arrowstyle 1,      "< tail -11 meterstanden.txt" using 2:1:2 with labels font "arial, 8"  offset 1.5,0.4


                                                                                                  ^
"figure02_temp.plt", line 37: warning: Skipping data file with no valid points

我无法弄清问题是什么,我错了什么?

(抱歉我的英格兰不好)

坦克为你的时间,它是剧本的一部分。

完整的脚本是;

set output "gnu.png"
set datafile separator ","
set style arrow 1 lw 3 lc rgb "#ff0000"
set style arrow 2 lw 3 lc rgb "#008000"
set style arrow 1 head size screen 0.02,90 # 0.02 is de breedte van het streepje, 90 is een platte streep.
set style arrow 2 head size screen 0.02,90 # 0.02 is de breedte van het streepje, 90 is een platte streep.
set linetype 1  lw 1 pointtype 0 lc rgb"#ff0000"

set bmargin 4 # witruimte onder grafiek
set label font "arial, 8" # grootte font tbv labels in het grafiek

set terminal png notransparent truecolor enhanced
set term png size 500, 450 background rgb "#ffffff"
set ydata time
set timefmt "%s"
set format y "%H:%M:%S"  # dit is de opmaak zoals je hem gaat zien

 #set key outside bot center
 #set key maxrows 1 # aantal regels onder het grafiek (met Watt/uur erin)

set title "Energiestroom" font "arial bold, 14"

set xtics font "arial, 10"
set ytics font "arial, 10"

set ylabel "T i j d - a s" offset 3,1 font "helvetica bold, 14"
set xlabel "W a t t / u u r" offset 0,0.5 font "arial bold, 14"

set grid xtics lc rgb "#dddddd" linewidth 2 lt 1
set grid ytics

set boxwidth 10
set style fill transparent solid 1
unset key

plot "< tail -10 meterstanden.csv" u (-100):1:2:0 title "", \
     "< tail -8 meterstanden.csv" u (0):1:($2<0 ?$2:0/0):(0) notitle with vectors arrowstyle 1, \
     "< tail -8 meterstanden.csv" u (0):1:($2>0 ?$2:0/0):(0) notitle with vectors arrowstyle 1, \
     "< tail -8 meterstanden.csv" u 2:1:2 with labels font "arial, 8"  offset 1.5,0.4  

情节是; http://ccvd.eu/downloads/gnu.png

在情节之后我得到错误。

我非常高兴你的解决方案。当Gnuplot给出时,Linux给了我一封邮件 麻烦。现在结束了,非常感谢。

这里结果是一个水平的“直方图”。 。 。红色和绿色。 http://ccvd.eu/downloads/gnu1.png

再一次,非常非常感谢。

亲切的问候,Con。

1 个答案:

答案 0 :(得分:0)

这是一个警告,而不是错误。原因是,文件的最后8行(假设您显示的数据是文件meterstanden.csv)都具有负值。因此,绘图中应该绘制正箭头的第三行只有0/0个值。但情节是正确的。

在您的情况下,您可以使用arrowstyle variable选项,该选项根据using语句中的最后一列选择箭头样式。这更容易,你不会收到任何警告:

plot "< tail -10 meterstanden.csv" u (-100):1:2:0 title "", \
     "< tail -8 meterstanden.csv" u (0):1:2:(0):($2 < 0 ? 1 : 2) notitle with vectors arrowstyle variable,\
     "< tail -8 meterstanden.csv" u 2:1:2 with labels font "arial, 8"  offset 1.5,0.4