如何绘制多个Y轴? [英] How to plot multiple y-axes?

查看:93
本文介绍了如何绘制多个Y轴?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了这张图,只是出于好奇的缘故,我想知道是否有可能像图中

I saw this graph and only for the curiosity sake was wondering whether it was possible to plot figure with multiple y-axis as in the figure

非常感谢!

推荐答案

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

As andyras wrote, you can use the second y-axis if you only have two datasets. In this case, you also need to to

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-tic和y-tick位置的数量相同.

If you want to plot more than one dataset, I would suggest to use multiplot. You can overlay several independent plots and put a unique offset to the y-axis for each of them. However, you need to take care that the number of y-tics and y-tick positions is the same.

情节:

(我不在乎这里的键,这仍然需要调整)

(I did not care about the key here, this still needs adjustment)

代码:

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

这篇关于如何绘制多个Y轴?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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