如何在 GNUPLOT 中绘制实时数据?数据来自不断向其记录新数据的文件

How can I plot Real-Time data in GNUPLOT? The data is coming from a file that is constantly recording new data to it

我希望能够使用 gnuplot 绘制数据 'real-time' 具体来说,例如, 我有一个文件 "foo.st",它是一个数据文件,由列分隔。 "foo.st" 中的数据是从实时变量中实时收集的 我想打开 gnuplot 并将来自 "foo.st" 的数据绘制为它的连续记录数据。理想情况下,我希望绘图显示“1 秒”的绘图,然后刷新显示下一个“1 秒”的数据,然后再次刷新显示下一个“1 秒”的数据...... 现在,我有一个 gnuplot 脚本 "foo.p" 上面写着:

set autoscale
set xtic auto
set ytic auto
set title "Leg Position"
set xlabel "Time (sec)"
set ylabel "Position"
plot "foo.st" u 1:2,'' u 1:3,'' u 1:4,'' u 1:5,'' u 1:6,'' u 1:7
pause 1
replot
set xrange [1:2]
replot
pause 1
set xrange [2:3]
replot
pause 1
set xrange [3:4]
replot
...

等等,我一直不得不重新定义 xrange 以显示 1 秒的数据帧,然后 运行 replot 命令。

任何人都可以提供任何其他建议来解决这个问题吗?

gnuplot 4.6 引入循环(while () {..}do for [] {..})。

如果无法升级:

 if !exists("t") t=0
 dt=1
 set xr [t:t+dt]
 plot "data"
 pause 1
 t=t+1
 reread

但我建议使用 while 循环。