如何全屏显示特定大小的gnuplots? [英] How to open gnuplots in full screen and a particular size?

查看:85
本文介绍了如何全屏显示特定大小的gnuplots?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在gnuplot中绘制图形,并希望以全屏和特定大小打开它们.

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. 如何全屏打开多图文件?
  2. 如何使输出文件具有特定大小?

这是我当前的gnuplot代码(在名为gnuplotCode的文件中):

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

我尝试键入以下内容:

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

和:

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

,但两种方法均无效.请您告诉我如何在全屏和特定尺寸下打开gnuplots吗?谢谢.

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

推荐答案

您必须区分基于像素的终端(pngcairopngcanvas(...)和所有交互式终端wxtx11qtwindowsaqua,其中大小以像素为单位;对于基于矢量的终端(postscriptsvgpostscript等),大小以英寸或英寸为单位厘米.

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.

使用-geometry标志仅对x11终端有效:

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

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

对于所有其他基于像素的终端,您可以使用size选项以像素为单位设置画布大小:

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. 在外壳上提取监视器大小:

  1. Extract the monitor size on the shell:

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

然后,文件gnuplotCode必须使用gnuplot变量monitorSize,如下所示:

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

请注意,字符串变量monitorSize的内容必须用作宏,即在评估整行之前插入值.

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.

如果您不希望在外壳上添加该行,则还可以通过system函数从gnuplot脚本中调用xrand内容.在这种情况下,文件gnuplotCode如下所示:

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

只能用gnuplot gnuplotCode调用.

请注意,shell命令始终总是仅提取第一个监视器的信息.

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

这篇关于如何全屏显示特定大小的gnuplots?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆