轴线样式

此示例显示了轴样式的一些配置。

轴线样式示例

  1. from mpl_toolkits.axisartist.axislines import SubplotZero
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. if 1:
  5. fig = plt.figure(1)
  6. ax = SubplotZero(fig, 111)
  7. fig.add_subplot(ax)
  8. for direction in ["xzero", "yzero"]:
  9. # adds arrows at the ends of each axis
  10. ax.axis[direction].set_axisline_style("-|>")
  11. # adds X and Y-axis from the origin
  12. ax.axis[direction].set_visible(True)
  13. for direction in ["left", "right", "bottom", "top"]:
  14. # hides borders
  15. ax.axis[direction].set_visible(False)
  16. x = np.linspace(-0.5, 1., 100)
  17. ax.plot(x, np.sin(x*np.pi))
  18. plt.show()

下载这个示例