简体   繁体   English

gnuplot - 如何保存与我在 xterminal 中设计的图形相同的图形文件?

[英]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:这是我到目前为止所做的:

  • I set up a cron job so they would be run right at midnight, capturing the whole day and saving it as a .png file我设置了一个 cron 作业,以便它们在午夜运行,捕获一整天并将其保存为 .png 文件
  • Then it moves the "today.dat" data file to the archive named by date.然后它将“today.dat”数据文件移动到以日期命名的存档中。
  • This part is all working as designed.这部分都按设计工作。

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:但是,如果您确实需要精确的副本,则(至少)有两种选择:

  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.您甚至可以在 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。

  2. 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.

相关问题 如何在同一个绘图上绘制2个图形,以便我可以比较它们 - how to draw 2 graphics on the same plot so I can compare them 如何用gnuplot绘制这样的Lennard Jones电位? - How can I plot a Lennard Jones Potential like this one with gnuplot? 我如何使用matplotlib绘制像gnuplot的'with impulses'这样的风格? - How can I plot a style like gnuplot's 'with impulses' with matplotlib? 如何使用 `ggsave` 保存相同的绘图(显示为 Plots&gt;Export&gt;Save)? - How can I save the same plot (shown with Plots>Export>Save) using `ggsave`? 我可以在Chart :: Gnuplot(Perl)中填充图吗? - Can I pad a plot in Chart::Gnuplot (Perl)? 如何从标准输入读取数据到 gnuplot 和 plot 相同数据两次 - How do I read data from stdin to gnuplot and plot same data twice 在Gnuplot中,按标题名称进行绘图时,如何绘制两列的总和 - In Gnuplot, how can I plot the sum of two columns when I'm plotting by header name 如何使用存储在同一文件中的数字使用 gnuplot 的绘图操作数据? - how to manipulate data with gnuplot's plot with a number stored in the same file? gnuplot-如何计算csv文件列中的条目数? - gnuplot - How can I count the number of entries in a csv file column? 如何在GNUPLOT中绘制实时数据? 数据来自一个不断向其记录新数据的文件 - How can I plot Real-Time data in GNUPLOT? The data is coming from a file that is constantly recording new data to it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM