19

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?

27

Use the -p or --persist option:

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.
  • 1
    as zoom doesn't work with --persist, SDsolar answer is better if you need zoom – lepe Apr 3 '18 at 1:35
  • I have a temporary plot file that I want to remove as soon as gnuplot is done (window closed). With the -p option gnuplot invoked from my shell exits immediatly, Suggestions? – rew Oct 4 '18 at 11:54
6

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 Ctrl-C

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.gp to edit the program from within the gnuplot environment, then the load "plotpgm.gp command to start it up again.


4

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 --persist or reread.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.