在窗口关闭的Gnuplot出口

时间:2015-03-15 17:09:52

标签: gnuplot

我使用以下脚本打印.csv文件中的读数。 绘图每秒刷新一次,以在模拟运行时显示新数据。这有点不错,虽然有点难看,因为整个数据集都被重读(如果你有更好的解决方案,请告诉我)

但是,当我关闭gnuplot窗口时,脚本不会退出,但是暂停1秒后会产生一个新窗口,这有点烦人。关闭窗口后,我宁愿关闭脚本。有没有办法实现这个目标?

#!/usr/bin/gnuplot
set t wxt enhanced noraise
set datafile separator ";"
plot "../build/inputLink.csv" using 1:5 title 'Input Gear' with lines ,\
     "../build/inputLink.csv" using 1:7 title 'Input Gear Ratio' with lines,\
     ;
pause 1
reread

2 个答案:

答案 0 :(得分:4)

在gnuplot中没有这样的功能,绑定窗口的close按钮以退出程序。但是,您可以使用bind来定义退出循环的热键:

#!/usr/bin/gnuplot
set t wxt enhanced noraise
set datafile separator ";"
set style data lines

done = 0
bind all 'd' 'done = 1'
while(!done) {
  plot "../build/inputLink.csv" using 1:5 title 'Input Gear',\
       "" using 1:7 title 'Input Gear Ratio'
  pause 1
}

不,除了每次重读整个数据集之外,没有其他方法可以刷新情节。

答案 1 :(得分:2)

读取/重新读取写入文件的最后100行,这些行附加了任何新数据

plot "< tail -n 100 ../build/inputLink.csv" using 1:5 title \
'Input Gear' with lines , \
, "< tail -n 100"../build/inputLink.csv" using 1:7 title \
'Input Gear Ratio' with lines,\
     ;

我的debian系统上没有wxt类型的终端,使用x11终端我可以绑定密钥's'并用它来退出gnuplot窗口

pause 1
bind "s" "unset output ; exit gnuplot"
reread