34

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

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

4

2 回答 2

52

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

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

脚本的输出

于 2012-05-22T18:24:29.197 回答
12

可以为 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
于 2010-05-14T15:51:57.937 回答