简单轴方向03

简单轴方向03

  1. import matplotlib.pyplot as plt
  2. import mpl_toolkits.axisartist as axisartist
  3. def setup_axes(fig, rect):
  4. ax = axisartist.Subplot(fig, rect)
  5. fig.add_subplot(ax)
  6. ax.set_yticks([0.2, 0.8])
  7. ax.set_xticks([0.2, 0.8])
  8. return ax
  9. fig = plt.figure(1, figsize=(5, 2))
  10. fig.subplots_adjust(wspace=0.4, bottom=0.3)
  11. ax1 = setup_axes(fig, "121")
  12. ax1.set_xlabel("X-label")
  13. ax1.set_ylabel("Y-label")
  14. ax1.axis[:].invert_ticklabel_direction()
  15. ax2 = setup_axes(fig, "122")
  16. ax2.set_xlabel("X-label")
  17. ax2.set_ylabel("Y-label")
  18. ax2.axis[:].major_ticks.set_tick_out(True)
  19. plt.show()

下载这个示例