12

I have a gnuplot script. My system is ubuntu 14.04. When In the terminal I type gnuplot myPlot. The plot will disappear. It is not remain on the screen. I this stack in saw similar question. But its system is windows. I want to know is there any solution for that on ubuntu 14.04 32 bit

PS: when I use gnuplot>-- I mean when I do not use script file-- I see the diagram and it does not disappear.

PS2 : this is my simple gnuplot script file :

set boxwidth 0.5
set style fill solid
plot "dataFile" using 1:2:xtic(2) with boxes
Community
  • 1
  • 1
alex
  • 1,319
  • 3
  • 16
  • 28

3 Answers3

17

If you want the plotting window to remain open, you must call gnuplot with the -persist flag:

gnuplot -persist myPlot
Christoph
  • 47,569
  • 8
  • 87
  • 187
  • 2
    Keep in mind that the `--persist` option will possibly disable mousing and any other interaction with the plotted graph when an interactive terminal such as `qt` is used. Check [here](https://sourceforge.net/p/gnuplot/bugs/1483/) for detailed explanation. – 0x450 Apr 09 '18 at 08:32
  • @Wolf: `man gnuplot` shows the option as -p as first in the section OPTIONS. I'm using version 5.2, so maybe it's a newer documentation than yours was. – user unknown Jan 26 '21 at 13:35
  • @userunknown maybe, now (gnuplot 5.2 patch level 6) I tried `gnuplot --help` in the command line and got this option listed (`-p --persist`), I'll remove these comments... – Wolf Jan 26 '21 at 13:52
14

There are already nice answers here, but the -persist flag did not work for me and enabling x11 force GnuPlot to use crapy XQuarts for windowing instead of beloved Qt. What worked for me was the

pause -1

command (from here) at the end of the script. According to the documentation

pause -1 # Wait until a carriage return is hit

I hope it helps.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
10

If you do not want to call gnuplot with the extra argument (-persist), you can enable this functionality within your script, e.g.

set term x11 persist
phadjido
  • 394
  • 3
  • 9