[英]gnuplot - How can I save a graphics file of a plot that is the same as I designed it in xterminal?
I have been making plots for some time now, and they are precisely the way I like them, on screen.我已经制作了一段时间的情节,它们正是我喜欢它们的方式,在屏幕上。 The data is coming in from sensors related to solar power collection and storage.
数据来自与太阳能收集和存储相关的传感器。
Plotted on screen they look great so I do a screen region capture to save them.绘制在屏幕上它们看起来很棒,所以我做了一个屏幕区域捕获来保存它们。
So now I would like to automate the saving process.所以现在我想自动化保存过程。
Here is what I have done so far:这是我到目前为止所做的:
EXCEPT, by using .PNG the images do not look the same.除了,通过使用 .PNG 图像看起来不一样。 I really thought png would be the best option, but it turns out that the font used for the X-axis (HH:MM ticks) is too thick and they run together.
我真的认为 png 将是最好的选择,但事实证明用于 X 轴(HH:MM 刻度)的字体太厚,它们一起运行。 It looks like a crayon-drawn version of my plot designs.
它看起来像是我的情节设计的蜡笔画版本。
Can someone please give me some guidance on how to best programatically generate the plots for saving so they look like the way I designed them?有人可以给我一些指导,告诉我如何最好地以编程方式生成要保存的图,使它们看起来像我设计的那样吗?
As pointed out in the comments above, the best way is probably to use a different terminal for output to an image file, and simply ignore the fact that the generated images are not identical to what you see on your screen when using the x11 terminal.正如上面的评论所指出的那样,最好的方法可能是使用不同的终端来输出到图像文件,并且只需忽略生成的图像与使用 x11 终端时在屏幕上看到的不同的事实。 However, if you really need an exact copy, there are (at least) two options:
但是,如果您确实需要精确的副本,则(至少)有两种选择:
You could automate the process of taking a screenshot.您可以自动化截取屏幕截图的过程。 You can even do this from within gnuplot, where it might come handy that the
GPVAL_TERM_WINDOWID
variable contains the X Windows ID for the current plot window.您甚至可以在 gnuplot 中执行此操作,在其中
GPVAL_TERM_WINDOWID
变量包含当前绘图窗口的 X Windows ID 可能会派上用场。 You can use that to make a screenshot of the window after you made the plot:您可以在绘制后使用它来制作窗口的屏幕截图:
system(sprintf("xwd -id 0x%x | convert xwd:- screenshot.png", GPVAL_TERM_WINDOWID))
Here I included a call to convert
to convert the xwd file format to png.在这里,我包含了一个调用
convert
将 xwd 文件格式转换为 png。
Another option is to use the xlib
terminal, which saves the sequence of commands that the gnuplot_x11
helper application turns into the window you see on the screen.另一种选择是使用
xlib
终端,它保存gnuplot_x11
助手应用程序变成您在屏幕上看到的窗口的命令序列。 For example,例如,
set term push; set term xlib; set output "file.xlib"; replot; set output; set term pop
will create the file file.xlib
that has all the information of the last plot.将创建文件
file.xlib
,其中包含最后一个绘图的所有信息。 To later view this plot, use要稍后查看此图,请使用
gnuplot_x11 -noevents -persist < file.xlib
where you might have to specify the path to gnuplot_x11
.您可能必须在其中指定
gnuplot_x11
的路径。
Similar as @user8153 suggested for x11
, you can use import
, which is as convert
an imagemagick tool与为
x11
建议的 @user8153 类似,您可以使用import
,这是convert
imagemagick 工具
system("import -window ".GPVAL_TERM_WINDOWID." screenshot.png")
Convenient is also a shortcut to copy the image into clipboard and paste it with Ctrl + v elsewhere:方便也是将图像复制到剪贴板并使用Ctrl + v粘贴到其他地方的快捷方式:
bind Ctrl-c 'system("import -window ".GPVAL_TERM_WINDOWID." png:- | xclip -sel clip -t image/png")'
See also Show graph on display and save it to file simultaneously in gnuplot .另请参阅在显示器上显示图形并将其同时保存到 gnuplot 中的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.