Matplotlib /
Pyplot:如何一起放大子图?
http://matplotlib.org/examples/pylab_examples/shared_axis_demo.html
http://matplotlib.org/users/recipes.html
引用最后一个链接:
Fernando Perez提供了一种很好的顶级方法,可以一次在subplots()中创建所有内容(最后请注意“
s”),然后关闭整个对象的x和y共享。您可以单独打开轴的包装:# new style method 1; unpack the axesfig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True,sharey=True)
ax1.plot(x)或以支持numpy索引的numrow x numcolumns对象数组的形式返回它们:
# new style method 2; use an axes arrayfig, axs = plt.subplots(2, 2, sharex=True, sharey=True)axs[0,0].plot(x)
如果您使用的是以下版本的旧版本,则
matplotlib该方法应该有效(也引用了最后一个链接)
轻松创建子图在matplotlib的早期版本中,如果要使用pythonic
API并创建图形实例,然后从中创建子图网格(可能带有共享轴),则需要大量样板代码。例如# old stylefig = plt.figure()ax1 = fig.add_subplot(221)ax2 = fig.add_subplot(222, sharex=ax1, sharey=ax1)ax3 = fig.add_subplot(223, sharex=ax1, sharey=ax1)ax3 = fig.add_subplot(224, sharex=ax1, sharey=ax1)



