在 gnuplot 中绘制两个轴

发布于 2024-09-01 10:01:36 字数 140 浏览 5 评论 0原文

是否可以在 gnuplot 中绘制两条曲线,其中有两个相应的轴,每个轴都有不同的比例?

例如,同一个图表中的 y=x**2y=x**4(当使用相同比例绘制时,它们的变化足以“令人不舒服”) 。

Is it possible to plot two curves, with two corresponding axes in gnuplot, each of which has a different scale?

For example, y=x**2 and y=x**4 in the same graph (they vary enough to be "uncomfortable" when plotted with the same scale).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

桃扇骨 2024-09-08 10:01:36

您可以自动处理轴,而无需自己缩放并保持自动缩放:

set terminal jpeg
set output 'graph.jpg'

set xrange [-10:10]
set ytics 10 nomirror tc lt 1
set ylabel '2*x' tc lt 1
set y2tics 20 nomirror tc lt 2
set y2label '4*x' tc lt 2
plot 2*x linetype 1, 4*x linetype 2 axes x1y2

脚本的输出

You can have the axes handled automatically without you having to scale them yourself and keep auto-scaling:

set terminal jpeg
set output 'graph.jpg'

set xrange [-10:10]
set ytics 10 nomirror tc lt 1
set ylabel '2*x' tc lt 1
set y2tics 20 nomirror tc lt 2
set y2label '4*x' tc lt 2
plot 2*x linetype 1, 4*x linetype 2 axes x1y2

output of the script

墨离汐 2024-09-08 10:01:36

可以为 y 和 y2(右轴)设置不同的范围,甚至可以独立设置标签/抽签的颜色。

然后我们只需将第二个函数除以 2(或适当的值)并设置颜色...如本例所示:

set xrange [-10:10]
set yrange [-20:20]
set y2range [-40:40]

set ytics 10 nomirror tc lt 1
set ylabel '2*x' tc lt 1

set y2tics 20 nomirror tc lt 2
set y2label '4*x' tc lt 2

plot 2*x linetype 1, 4*x/2+.5 linetype 2

It is possible to set different ranges for y and y2 (the right axes), and even to set the color of the labels/tics independently.

Then we simply divide the second function by 2 (or something appropriate) and set the colors... as in this example:

set xrange [-10:10]
set yrange [-20:20]
set y2range [-40:40]

set ytics 10 nomirror tc lt 1
set ylabel '2*x' tc lt 1

set y2tics 20 nomirror tc lt 2
set y2label '4*x' tc lt 2

plot 2*x linetype 1, 4*x/2+.5 linetype 2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文