如何绘制多个y轴?

kuk*_*uki 6 gnuplot

我看到了这张图,只是为了好奇,想知道是否有可能用多个y轴绘制图形,如图所示 在此输入图像描述

非常感谢!

swe*_*ber 6

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

set ytics nomirror # remove the tickmarks of the left ayis on the right side
set y2tics         # make the right y-axis 'visible'
Run Code Online (Sandbox Code Playgroud)

如果你想绘制多个数据集,我建议使用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
Run Code Online (Sandbox Code Playgroud)