如何创建具有链接(共享)x轴的绘图堆栈,这些x轴在缩放期间自动缩放所有“从属”绘图的y轴?例如:
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212, sharex=ax1)
ax1.plot([0,1])
ax2.plot([2,1])
plt.show()
当我放大ax1时,这也会更新ax2的x轴(到目前为止还不错),但我也希望ax2的y轴根据现在可见的数据范围自动缩放。所有自动缩放设置都处于启用状态(默认设置)。创建ax2后手动设置自动缩放设置无济于事:
ax2.autoscale(enable=True, axis='y', tight=True)
ax2.autoscale_view(tight=True, scalex=False, scaley=True)
print ax2.get_autoscaley_on()
-> True
我错过了什么吗?
https://stackoverflow.com/questions/11086724
复制相似问题