[英]matplotlib share xaxis with yaxis from another plot
如果我想将两个单独轴的 x 轴和 y 轴连接在一起,以便它们一起缩放,我通常会执行以下操作:
fig = plt.figure()
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122,sharex=ax1, sharey=ax1)
但我不知道如何将一个图的 x 轴与另一个图的 y 轴共享。 例如,一个绘图的 x 轴是“时间”,我想与另一个也代表“时间”的绘图的 y 轴共享它。 像这样的东西(不起作用......):
ax2 = fig.add_subplot(122,sharex=ax1.yaxis, sharey=ax1.xaxis)
谢谢
我会做这样的事情,
fig, axs = plt.subplots(3, sharex=True, sharey=True) //Here
fig.suptitle('Sharing both axes')
axs[0].plot(x, y ** 2)
axs[1].plot(x, 0.3 * y, 'o')
axs[2].plot(x, y, '+')
##As per matplotlib docs,对我来说也很好用另一种方法是你也可以叠加。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.