Gridspec演示03

Gridspec演示03

  1. import matplotlib.pyplot as plt
  2. from matplotlib.gridspec import GridSpec
  3. def make_ticklabels_invisible(fig):
  4. for i, ax in enumerate(fig.axes):
  5. ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
  6. ax.tick_params(labelbottom=False, labelleft=False)
  7. # demo 3 : gridspec with subplotpars set.
  8. fig = plt.figure()
  9. fig.suptitle("GridSpec w/ different subplotpars")
  10. gs1 = GridSpec(3, 3)
  11. gs1.update(left=0.05, right=0.48, wspace=0.05)
  12. ax1 = plt.subplot(gs1[:-1, :])
  13. ax2 = plt.subplot(gs1[-1, :-1])
  14. ax3 = plt.subplot(gs1[-1, -1])
  15. gs2 = GridSpec(3, 3)
  16. gs2.update(left=0.55, right=0.98, hspace=0.05)
  17. ax4 = plt.subplot(gs2[:, :-1])
  18. ax5 = plt.subplot(gs2[:-1, -1])
  19. ax6 = plt.subplot(gs2[-1, -1])
  20. make_ticklabels_invisible(fig)
  21. plt.show()

下载这个示例