Gnuplot 如何绘制多个y轴?

Gnuplot 如何绘制多个y轴?,gnuplot,Gnuplot,我看到了这张图,只是出于好奇,我想知道是否有可能像图中那样用多个y轴绘制图 非常感谢 是的,您可以免费使用两个y轴,例如 plot x, x**2 axes x1y2 axes规范允许您将内容放在x1y1、x2y1等上。如果您希望在同一y轴上绘制两个以上的内容,您必须自己进行规范化: plot 'data1.dat' using 1:($2/MAX_1), \ 'data2.dat' using 1:($2/MAX_2), \ 'data3.dat' using 1:($s/MAX_3

我看到了这张图,只是出于好奇,我想知道是否有可能像图中那样用多个y轴绘制图


非常感谢

是的,您可以免费使用两个y轴,例如

plot x, x**2 axes x1y2
axes
规范允许您将内容放在
x1y1
x2y1
等上。如果您希望在同一y轴上绘制两个以上的内容,您必须自己进行规范化:

plot 'data1.dat' using 1:($2/MAX_1), \
  'data2.dat' using 1:($2/MAX_2), \
  'data3.dat' using 1:($s/MAX_3)

变量
MAX_X
可以通过使用gnuplot 4.6+中的
stats
命令预先计算,也可以手动输入。

正如andyras所写,如果只有两个数据集,可以使用第二个y轴。在这种情况下,您还需要

set ytics nomirror # remove the tickmarks of the left ayis on the right side
set y2tics         # make the right y-axis 'visible'
如果要绘制多个数据集,我建议使用
multiplot
。可以覆盖多个独立的绘图,并为每个绘图向y轴放置唯一的偏移。 但是,您需要注意y-tics和y-tick位置的数量是相同的

绘图:

set multiplot


set xrange[0:10]

# We need place to the left, so make the left margin 30% of screen
set lmargin screen 0.3

##### first plot

set ytics 0.4
set yrange[-1.2:1.2]

set ylabel "Voltage" textcolor rgb "red"

plot sin(x)


##### Second plot

set ytics 1
set yrange[-3:3]

set ytics offset  -8, 0
set ylabel "Current" offset -8, 0 textcolor rgb "green"

plot 3*cos(x) linecolor 2

##### Third plot

set ytics 0.5
set yrange[-1.5:1.5]


set ytics offset -16, 0
set ylabel "Power" offset -16, 0  textcolor rgb "blue"
plot 3*sin(x)*cos(x) linecolor 3

unset multiplot

(我不在乎这里的钥匙,这还需要调整)

代码:

set multiplot


set xrange[0:10]

# We need place to the left, so make the left margin 30% of screen
set lmargin screen 0.3

##### first plot

set ytics 0.4
set yrange[-1.2:1.2]

set ylabel "Voltage" textcolor rgb "red"

plot sin(x)


##### Second plot

set ytics 1
set yrange[-3:3]

set ytics offset  -8, 0
set ylabel "Current" offset -8, 0 textcolor rgb "green"

plot 3*cos(x) linecolor 2

##### Third plot

set ytics 0.5
set yrange[-1.5:1.5]


set ytics offset -16, 0
set ylabel "Power" offset -16, 0  textcolor rgb "blue"
plot 3*sin(x)*cos(x) linecolor 3

unset multiplot

谢谢你,斯威伯!但这个offset命令仍然令人困惑。偏移量-8或-16的参考线是什么?默认偏移量是0,因此在我的绘图中,参考是电压轴。如果指定它,还可以指定一个单位,例如
偏移屏幕-0.2,0
,表示窗口左侧宽度的20%。如果没有
屏幕
,我想它需要一些字符宽度/高度。字符大小是一个不常见但经常有用的单位。谢谢你的解释!我遵循了上面的示例,但不知道如何分离右上角的3个标签(在我的例子中为2个)。我尝试了“偏移量t-1,0”之类的方法,但没有成功。现在我把它们倒空了:“t”。有什么想法吗?