Bezier曲线

此示例展示 PathPatch 对象以创建Bezier多曲线路径修补程序。

  1. import matplotlib.path as mpath
  2. import matplotlib.patches as mpatches
  3. import matplotlib.pyplot as plt
  4. Path = mpath.Path
  5. fig, ax = plt.subplots()
  6. pp1 = mpatches.PathPatch(
  7. Path([(0, 0), (1, 0), (1, 1), (0, 0)],
  8. [Path.MOVETO, Path.CURVE3, Path.CURVE3, Path.CLOSEPOLY]),
  9. fc="none", transform=ax.transData)
  10. ax.add_patch(pp1)
  11. ax.plot([0.75], [0.25], "ro")
  12. ax.set_title('The red point should be on the path')
  13. plt.show()

Bezier曲线示例

参考

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

  1. import matplotlib
  2. matplotlib.path
  3. matplotlib.path.Path
  4. matplotlib.patches
  5. matplotlib.patches.PathPatch
  6. matplotlib.axes.Axes.add_patch

下载这个示例