Gridspec演示05

Gridspec演示05

  1. import matplotlib.pyplot as plt
  2. import matplotlib.gridspec as 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. f = plt.figure()
  8. gs = gridspec.GridSpec(2, 2,
  9. width_ratios=[1, 2], height_ratios=[4, 1])
  10. ax1 = plt.subplot(gs[0])
  11. ax2 = plt.subplot(gs[1])
  12. ax3 = plt.subplot(gs[2])
  13. ax4 = plt.subplot(gs[3])
  14. make_ticklabels_invisible(f)
  15. plt.show()

下载这个示例