我是个新手,他第一次接触到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)。
你能帮我一下吗?
发布于 2015-02-22 20:39:36
您是否尝试分别绘制每条曲线,并最终使用一条plt.show()?
这将在同一张图上绘制曲线,但您必须提供y值的偏移量。
https://stackoverflow.com/questions/28520226
复制相似问题