For example, this keeps the
gnuplot-x11 graph window open until a key is pressed:
gnuplot -e "plot \"file\" ; pause -1 \"text\""
How to keep it open until manually closed?
gnuplot --persist -e 'plot sin(x)'
This will keep the window open until manually closed. From the man page:
-p, --persist lets plot windows survive after main gnuplot program exits.
You can make your plot program periodically refresh, making it into a live graph. This is most commonly used for data loggers where the file is being updated.
But in reference to your question it holds the plot open, refreshing, until you press
Simply add these two lines to the end of your plot program:
pause 30 reread
One advantage to doing it this way is that you do not need to exit the gnuplot environment to use it, especially while debugging. When you stop the plot you are returned to the gnuplot prompt. You can still use
!vi plotpgm.gpto edit the program from within the gnuplot environment, then the
load "plotpgm.gpcommand to start it up again.
You'd better use
pause mouse close at the end of the script. This way you will have control over the plot with mouse and various keybindings w/o any extra polling, unlike