简单轴分割器示例2

简单轴分割器示例2

  1. import mpl_toolkits.axes_grid1.axes_size as Size
  2. from mpl_toolkits.axes_grid1 import Divider
  3. import matplotlib.pyplot as plt
  4. fig1 = plt.figure(1, (5.5, 4.))
  5. # the rect parameter will be ignore as we will set axes_locator
  6. rect = (0.1, 0.1, 0.8, 0.8)
  7. ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]
  8. horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.),
  9. Size.Scaled(.5)]
  10. vert = [Size.Scaled(1.), Size.Fixed(.5), Size.Scaled(1.5)]
  11. # divide the axes rectangle into grid whose size is specified by horiz * vert
  12. divider = Divider(fig1, rect, horiz, vert, aspect=False)
  13. ax[0].set_axes_locator(divider.new_locator(nx=0, ny=0))
  14. ax[1].set_axes_locator(divider.new_locator(nx=0, ny=2))
  15. ax[2].set_axes_locator(divider.new_locator(nx=2, ny=2))
  16. ax[3].set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0))
  17. for ax1 in ax:
  18. ax1.tick_params(labelbottom=False, labelleft=False)
  19. plt.show()

下载这个示例