gnuplot-如何保存与在xterminal中设计的图相同的图的图形文件? [英] gnuplot - How can I save a graphics file of a plot that is the same as I designed it in xterminal?

查看:51
本文介绍了gnuplot-如何保存与在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:

  • 我设置了一项cron作业,以便它们可以在午夜运行,捕获整天并将其保存为.png文件
  • 然后将"today.dat"数据文件移动到按日期命名的档案中.
  • 这部分均按设计工作.

此外,通过使用.PNG,图像看起来不一样.我真的以为png是最好的选择,但事实证明,用于X轴的字体(HH:MM刻度)太粗了,它们一起运行.它看起来像是我的情节设计的蜡笔绘制版本.

EXCEPT, by using .PNG the images do not look the same. 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. 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?

推荐答案

正如上面的注释所指出的,最好的方法可能是使用不同的终端输出到图像文件,而忽略了生成的事实.图像与使用x11终端时在屏幕上看到的图像不同.但是,如果您真的需要准确的副本,则至少有两个选择:

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. However, if you really need an exact copy, there are (at least) two options:

  1. 您可以自动执行截屏过程.您甚至可以在gnuplot内执行此操作,其中 GPVAL_TERM_WINDOWID 变量包含当前绘图窗口的X Windows ID可能很方便.绘制绘图后,可以使用它来制作窗口的屏幕截图:

  1. 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. 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))

这里我包含了对 convert 的调用,以将xwd文件格式转换为png.

Here I included a call to convert to convert the xwd file format to png.

另一种选择是使用 xlib 终端,该终端将 gnuplot_x11 辅助应用程序转换为您在屏幕上看到的窗口的命令序列保存.例如,

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. For example,

set term push; set term xlib; set output "file.xlib"; replot; set output; set term pop

将创建文件 file.xlib ,该文件具有最后一个绘图的所有信息.要稍后查看此图,请使用

will create the file file.xlib that has all the information of the last plot. To later view this plot, use

gnuplot_x11 -noevents -persist < file.xlib

您可能必须在其中指定 gnuplot_x11 的路径.

where you might have to specify the path to gnuplot_x11.

这篇关于gnuplot-如何保存与在xterminal中设计的图相同的图的图形文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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