0
votes

I have a datafile "data.dat", say.

When I enter the gnuplot shell by typing 'gnuplot', and then run the command

plot 'data.dat' u 1:2 w l

the plot appearing remains responsive, i.e, by right click of mouse I can zoom it or by arrow keys, I can move the plot up/down/side.

But when I try to do the same thing using a script file, I can no more use those right click zooming and all. My script file is named as p.plt, say and contains the following line -

plot 'data.dat' u 1:2 w l

Now, when I execute it with the command gnuplot -p p.plt, it no longer responds to those right clicks or arrow keys. What should I do to make it work with script files?

I am using linux mint 19.3 cinnamon and gnuplot version gnuplot 5.2 patchlevel 2.

1

1 Answers

1
votes

The -p option ("persist") tells gnuplot to leave the plot showing on the screen when the program exits. In this state, as you found, most mousing operations no longer work because the program is no longer there to respond to them. So "persist" is not what you want. Instead add a command to your script that tells the program to remain active until the plot window is closed:

  plot 'data.dat' u 1:2 w l
  pause mouse close

Exactly what operation or signal is interpreted as "close" depends on your window manager, desktop setup, and operating system. Usually there is widget somewhere on the window border (maybe a little "x" in the top corner?) and probably a hot-key ("alt-F4" on my desktop) also. You can supplement this by defining your own hotkey inside gnuplot:

  plot 'data.dat' u 1:2 w l
  bind all "alt-End" "exit gnuplot"
  pause mouse close

Now typing <alt>+<End> while the mouse is over any gnuplot window should cause the program to exit.