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

穿精又带淫゛_ 提交于 2019-11-29 06:14:43

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!