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
If you want the plotting window to remain open, you must call gnuplot with the -persist flag:
gnuplot -persist myPlot
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.
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
Related
I want graphs with lines to be generated in gnuplot rather than points in a terminal. I have only terminal to work with and no gui interface (Centos).
i tried installing png/wxt terminal which failed. I want the output to be saved in a file but with lines unlike one with dumb terminal.
Displaying nice graphics in a terminal emulator window or on the bare linux console
The current recommendation for displaying graphics from gnuplot to the linux console (i.e. no windowing system at all) is to use a console terminal emulator such as yaft (https://github.com/uobikiemukot/yaft) that supports sixel graphics. With yaft as your console terminal you can run gnuplot and select set term sixel to generate very nice in-line graphics.
You can do essentially the same thing using xterm, so long as your copy of xterm was built with sixel graphics support. You must select the vt340 emulation mode. This allows in-line graphics generated by a remote machine that you have connected to via ssh.
$ xterm -ti 340
xterm> ssh some.remote.machine
[remote prompt] gnuplot
gnuplot> set term sixel
gnuplot> plot ...
Generating graphics to a file from a dumb terminal window
However none of this is necessary in order to create an output file from a terminal that is not capable of graphics. Gnuplot terminals png/tikz/pdf/postscript/emf/... etc all work without any requirement for terminal display. You can preview the plot with set term dumb and then switch to your prefered format for saving to a file.
set term dumb
plot sin(x) with lines # ugly plot but indicates ranges, etc
set term pdf
set output 'myplot.pdf'
replot
I am having an issue where I am unable to zoom in on my GNUPLOT. I created a bash script that records various resource information, and displays this information via the following command.
gnuplot -e persist "set title 'Resource monitor' ; set timefmt '%y/%m/%d-%H:%M:%S' ; set xdata time ; set xlabel 'TIME' ; set ylabel 'PERCENT' set yrange [0:101]" -e "plot '${cpuResFile}' using 1:2 title 'CPU' smooth Bezier, '${memResFile}' using 1:2 title 'MEM' smooth Bezier" &
The graph is viewable and displays my information I want, I just cannot figure out how to allow it to zoom in and out. I read that it has something to do with the X11 window no longer being set or that I need to set it via the command line, I just cannot figure out exactly how to, or if this is even the reason. Hopefully there are a couple GNUPLOT experts that can assist me. :)
Thank you.
Zooming and unzooming isn't possible in interactive windows which are left open with the -persist flag. Those operations would require a redrawing which isn't possible anymore since the main programs has already exited.
Quoting from the persist documentation:
[...] gnuplot will open a display window, draw the plot into it, and then exit, leaving the display window containing
the plot on the screen. Depending on the terminal type, some mousing operations may still be possible in
the persistent window. However operations like zoom/unzoom that require redrawing the plot are generally
not possible because the main program has already exited
You could add pause -1 at the end of the command list:
gnuplot -e "plot sin(x); pause -1" &
I am using gnuplot on a hidpi screen (276 dpi).
The plots I recover are hard to see properly, the lines too thin, the fonts and buttons too small.
Is there any way to configure gnuplot to scale up these parameters for hidpi screens automatically upon start?
gnuplot automatically loads an initialisation file on startup, that you can use to change the default linewidths etc. It accepts normal gnuplot syntax. Check help initialization to see how it's named and where to place it on your system.
Use e.g. set terminal wxt lw 2 to change the absolute default linewidth. The sizes given in a later plot command are just multiplicators for the terminal setting. The pointsize and border/tics linewidth are scaled accordingly.
I have recently upgraded to Debian jessie, meaning that I have upgraded from gnuplot 4.6.0 to gnuplot 4.6.6 (issue is the same with gnuplot 5.0).
I have bash scripts automating things, and launching gnuplot terminal.
I was using either:
gnuplot -persist -e "set title 'Sine curve'; plot sin(x)"
or
gnuplot -persist <<EOF
set title 'Sine curve'
plot sin(x)
EOF
The terminal wxt is no more distributed by debian (and derivatives like ubuntu), because of #751441.
I am using now terminal qt. It displays the plot, but that's the end. The window is static and most of the buttons do not work. I cannot zoom, I cannot unzoom, I cannot show the grid.
How to circumvent this?
Answering my own question: I spent two much time googling, trying to understand why, reading excuses to not correct it, and finding workarounds.
First, you have to remove -persist because it has a wxt special way of working, and it is not the same way of working with qt terminal. See #1418.
Second, you have to add "pause mouse close" after your plot. See #1418. The script is now:
gnuplot -e "set title 'Sine curve'; plot sin(x); pause mouse close"
Now the zoom in, zoom out, and show grid are working.
Third, wait, you did not plotted a sinus, but with lines. Like this example:
$ gnuplot <<EOF
plot '-' using 1:2 t '' with line
0 0
10 10
e
pause mouse close
EOF
Now, if you zoom somewhere in the middle of a segment, you get nothing, an empty and blank screen. What you need is set clip two that tells to not clip when segments ends are not shown. See #1419. So the following will work:
$ gnuplot <<EOF
set clip two
plot '-' using 1:2 t '' with line
0 0
10 10
e
pause mouse close
EOF
Finally, what I have done, is:
add pause mouse close at the end of the script
add set clip two in ~/.gnuplot file
With this, I can mimic the wxt way of working while using qt terminal. IMHO, as a basic end-user, this should be the default.
Do we have a facility to rotate the image, using mouse, to see different views in gnuplot.
I wish gnuplot had similar facility to rotate the image as MATLAB has.
In my version it just works.
Version 4.4 patchlevel 0
last modified March 2010
You might need to change the terminal for gnuplot.
The window with the nice toolbar is generated by the "wxt" terminal.
gnuplot> set term wxt
Use 'set term' without parameters to show a list of available terminals.
gnuplot> set term