Plotting data in real time

From Docswiki
Jump to navigation Jump to search

If your code produces output in real time during a run, it can be both informative and interesting to be able to view the results as they come in. This can be done simply using the following two gnuplot scripts. Copy each into vi to produce the two script files test.plt and loop.plt

test.plt

#!/usr/bin/gnuplot -persist
# test.plt
reset
load "loop.plt"
reset

loop.plt

#!/usr/bin/gnuplot -persist
# loop.plt
plot 'out.dat' u 1:2 w l
reread

You of course need to edit loop.plt to your plotting specifications. Once you are happy - run gnuplot with:

 
gnuplot < test.plt

Thanks to Jason Green for the scripts :)