I would like to be able to plot data 'real-time' using gnuplot Specifically, for example, I have a file "foo.st" which is a data file, separated by columns. The data in "foo.st" is collected real-time from live variables I would like to have gnuplot open and plotting the data from "foo.st" as its continuously recording data. Ideally I want the plot to show a "1 second" plot, then refresh showing the next "1 second" of data, then refresh again showing the next "1 second" of data ... Right now, I have a gnuplot script "foo.p" which reads:
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
...
Etc I keep having to redefine the xrange to show a 1 second frame of data and then run the replot command.
Can anyone offer any other suggestions to go about this?
gnuplot 4.6 intruduced loops (while () {..}
, do for [] {..}
).
If you cannot upgrade:
if !exists("t") t=0
dt=1
set xr [t:t+dt]
plot "data"
pause 1
t=t+1
reread
But I'd recommend using a while
-loop.