如果您有多个子图包含二次y轴(使用twinx创建),那么您如何在子图之间共享这些辅助y轴?我希望他们以自动的方式平等地平衡(所以以后不要用手来设置y限制).
对于主y轴,这可以通过在子程序调用中使用关键字sharey来实现.
下面的示例显示了我的尝试,但是它无法共享两个子图的辅助y轴.我正在使用Matplotlib / Pylab:
ax = []
#create upper subplot
ax.append(subplot(211))
plot(rand(1) * rand(10),'r')
#create plot on secondary y-axis of upper subplot
ax.append(ax[0].twinx())
plot(10*rand(1) * rand(10),'b')
#create lower subplot and share y-axis with primary y-axis of upper subplot
ax.append(subplot(212, sharey = ax[0]))
plot(3*rand(1) * rand(10),'g')
#create plot on secondary y-axis of lower subplot
ax.append(ax[2].twinx())
#set twinxed axes as the current axes again,
#but now attempt to share the secondary y-axis
axes(ax[3], sharey = ax[1])
plot(10*rand(1) * rand(10),'y')
这让我有点像:
我使用axes()函数设置共享y轴的原因是twinx不接受sharey关键字.
我在Win7 x64上使用Python 3.2. Matplotlib版本是1.2.0rc2.
在Matplotlib中,当创建具有多个子图且每个子图都有二次y轴时,如何实现这些辅助y轴的共享和自动均衡。目前的代码示例展示了如何创建子图,但无法实现辅助y轴的共享。问题在于`twinx`函数不接受`sharey`参数,导致无法直接设置共享。寻求解决方案以避免手动调整y轴限制。
649

被折叠的 条评论
为什么被折叠?



