I have a data file a.dat
that is updated every few seconds. I wish to plot it in gnuplot every few seconds to see the changes
plot "a.dat"
What is the easiest way to do it? Thanks.
Make a script with a loop:
while (1) {
plot "a.dat"
pause 1 # waiting time in seconds
}
Execute it with gnuplot script.gp
.
For purposes of code structure and debugging, you might prefer the following alternative:
plot "a.dat"
while (1) {
replot
pause 1
}
This has the advantage that you do not have to put a complicated plot
command inside the loop and do not suffer from incorrect line numbers for the plot command in error messages (that happen in at least some version of Gnuplot).
Finally, if your Gnuplot is so old that it does not yet support loops, there is the alternative:
plot "a.dat"
pause 1
reread
With reread
making the script interpreter jump to the beginning of the file again.