Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
436 views
in Technique[技术] by (71.8m points)

output - How to open gnuplots in full screen and a particular size?

I am plotting graphs in gnuplot and would like to open them in full screen and a particular size.

Previously, I have been outputting graphs in multiplot mode and updating them using reread; so, when I maximise it manually, the plots fill the screen after a few iterations. Now, I also want to save the output as a file. When I open that file, it is in the same small size as the original multiplot output. However, when I maximise it, the plots don't increase in size to fill the screen. I have 2 questions:

  1. How can I open the multiplot file in full screen?
  2. How can I make the output file a particular size?

Here is my current gnuplot code (in a file called gnuplotCode):

set terminal pngcairo dashed enhanced
set output 'foo.png'
set multiplot layout 3, 3
plot for [iter=1:9] path/to/file using 1:(column(iter)) notitle
unset multiplot
unset output
pause 10
reread

I have tried to type the following:

gnuplot -geometry -3360-1050 gnuplotCode    # where my screen size is 3360x1050

and:

resolution=$(xrandr | grep '*') && resolution=${resolution%  *}
gnuplot -geometry $resolution gnuplotCode

but neither approach works. Please can you tell me how to open gnuplots in full screen and a particular size? Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You must distinguish between pixel-based terminals (pngcairo, png, canvas (...) and all interactive terminals wxt, x11, qt, windows, aqua, where the size is given in pixel. For vector-based terminals (postscript, svg, postscript etc) the size is given in inch or centimeters.

Using the -geometry flag works only for the x11 terminal:

gnuplot -geometry 800x800 -persist -e 'set terminal x11; plot x'

For all other pixel-based terminal you can use the size option to set the canvas size in pixel:

set terminal pngcairo size 800,800

Of course you can also extract the monitor resolution and use that as size. Here you have two variants:

  1. Extract the monitor size on the shell:

    monitorSize=$(xrandr | awk '/*/{sub(/x/,",");print $1; exit}')
    gnuplot -e "monitorSize='$monitorSize'; load 'gnuplotCode'"
    

    The file gnuplotCode must then use the gnuplot variable monitorSize as follows:

    set macros
    set terminal pngcairo size @monitorSize
    set output 'foo.png'
    plot x
    

    Note, that the content of the string variable monitorSize must be used as macro, i.e. the value is inserted before the whole line is evaluated.

  2. If you don't want to have that additional line on the shell, you could also call the xrand stuff from within the gnuplot script via the system function. In that case the file gnuplotCode would look as follows:

    monitorSize=system("xrandr | awk '/*/{sub(/x/,",");print $1; exit}'")
    set macros
    set terminal pngcairo size @monitorSize
    set output 'foobar.png'
    plot x**2
    

    which you must call only with gnuplot gnuplotCode.

Note, that the shell command as is always extracts the information of the first monitor only.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...