标记路径

使用路径(path)作为绘图的标记(plot)。

  1. import matplotlib.pyplot as plt
  2. import matplotlib.path as mpath
  3. import numpy as np
  4. star = mpath.Path.unit_regular_star(6)
  5. circle = mpath.Path.unit_circle()
  6. # concatenate the circle with an internal cutout of the star
  7. verts = np.concatenate([circle.vertices, star.vertices[::-1, ...]])
  8. codes = np.concatenate([circle.codes, star.codes])
  9. cut_star = mpath.Path(verts, codes)
  10. plt.plot(np.arange(10)**2, '--r', marker=cut_star, markersize=15)
  11. plt.show()

标记路径示例

参考

此示例中显示了以下函数,方法,类和模块的使用:

  1. import matplotlib
  2. matplotlib.path
  3. matplotlib.path.Path
  4. matplotlib.path.Path.unit_regular_star
  5. matplotlib.path.Path.unit_circle
  6. matplotlib.axes.Axes.plot
  7. matplotlib.pyplot.plot

下载这个示例