繁体   English   中英

Matplotlib:绘制偏移曲线,每个曲线都有相应的y轴

[英]Matplotlib: plot offset curves, each with corresponding y-axis

我是第一次接触Matplotlib的新手。 我想在同一个图中绘制一些(四个)不同的数据集,我需要抵消它们,否则它们会重叠。

这是我需要获得的: http//s4.postimg.org/skaclr06l/example.jpg

现在,将一个常量添加到不同的数据集以抵消它们会很简单,但我需要每个绘图都有一个从0开始的相应纵坐标轴,如我发布的示例所示。 我在matplotlib网站上找到了一个非常接近它的解决方案:

# Three subplots sharing both x/y axes
f, (ax1, ax2, ax3) = plt.subplots(3, sharex=True, sharey=True)
ax1.plot(x, y)
ax1.set_title('Sharing both axes')
ax2.scatter(x, y)
ax3.scatter(x, 2 * y ** 2 - 1, color='r')
# Fine-tune figure; make subplots close to each other and hide x ticks for
# all but bottom plot.
f.subplots_adjust(hspace=0)
plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False)

问题在于,通过这种方式,我获得了单独的图,而我希望它们部分重叠,例如,通常使用吸收光谱(参见此处的示例http://nte-serveur.univ-lyon1)。 fr / spectroscopie / raman / Image42.gif

你可以帮帮我吗?

你试图分别绘制每条曲线,最后使用一个plt.show()吗?

这将在同一图上绘制曲线,但您必须为y值提供偏移。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM