Gnuplot-在png终端上使用replot [英] Gnuplot - Using replot with png terminal

查看:62
本文介绍了Gnuplot-在png终端上使用replot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Gnuplot中将replot与png终端一起使用.

I am trying to use replot with png terminal in Gnuplot.

如果执行以下操作,我将在一张图中得到两个图,而不会出现任何问题:

If I do the following I get two plots on one graph without any problem:

plot sin(x)/x
replot sin(x)

现在,如果对png终端类型执行相同操作,则生成的png文件仅包含第一个图.

Now if do the same for a png terminal type the resulting png file only contains the first plot.

set terminal png
set output 'file.png'
plot sin(x)/x
replot sin(x)

我到底想在png文件中获取第二张图吗?

Am I missing something at the end to get the second plot in my png file?

推荐答案

这实际上是一个非常好的问题,此处的行为取决于终端.某些终端设备(例如,附言)将为每个replot提供一个新页面.您有几种解决方案...

This is actually a very good question, and the behavior here is terminal dependent. Some terminals (e.g. postscript) will give you a new page for each replot. You have a couple of solutions...

第一个选项:您可以在设置终端/输出之前进行绘制,然后在设置终端/输出之后再次重新绘制:

First Option: You can make your plot prior to setting the terminal/output and then replot again after you set the terminal/output:

plot sin(x)/x
replot sin(x)
set terminal png
set output 'file.png
replot

如果您想在多个终端中绘制相同的东西,则此选项有时很方便,但是我很少将其用于其他任何用途.

This option is sometimes convenient if you want to plot the same thing in multiple terminals, but I rarely use it for anything else.

第二个(更好的)选项:您可以将多个图打包到一个命令中,并用逗号分隔每个图.

Second (better) Option: You can pack multiple plots into one command separating each with a comma.

set terminal png
set output 'file.png'
plot sin(x)/x, sin(x)

我非常喜欢第二种方法-在多图环境中,这是在同一图上放置多个图形的唯一方法.如果要绘制的函数很长,则可以使用gnuplot的行连续符来中断行(\在行的末尾–在\之后不允许输入任何内容,甚至不能使用空格)

I very much prefer the second way -- when in a multiplot environment, this is the only way to put multiple graphs on the same plot. If you have very long functions to plot, you can break the line with gnuplot's line continuation (\ at the end of the line -- Nothing is allowed after the \, not even whitespace)

plot sin(x)/x with lines linecolor rgb "blue" linetype 7 lineweight 4, \
     sin(x),                                                           \
     cos(x)

这篇关于Gnuplot-在png终端上使用replot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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