简单的轴线2

简单的轴线2

  1. import matplotlib.pyplot as plt
  2. from mpl_toolkits.axisartist.axislines import SubplotZero
  3. import numpy as np
  4. fig = plt.figure(1, (4, 3))
  5. # a subplot with two additional axis, "xzero" and "yzero". "xzero" is
  6. # y=0 line, and "yzero" is x=0 line.
  7. ax = SubplotZero(fig, 1, 1, 1)
  8. fig.add_subplot(ax)
  9. # make xzero axis (horizontal axis line through y=0) visible.
  10. ax.axis["xzero"].set_visible(True)
  11. ax.axis["xzero"].label.set_text("Axis Zero")
  12. # make other axis (bottom, top, right) invisible.
  13. for n in ["bottom", "top", "right"]:
  14. ax.axis[n].set_visible(False)
  15. xx = np.arange(0, 2*np.pi, 0.01)
  16. ax.plot(xx, np.sin(xx))
  17. plt.show()

下载这个示例