貝茲曲線#

此範例展示 PathPatch 物件,以建立貝茲複合曲線路徑補丁。

import matplotlib.pyplot as plt

import matplotlib.patches as mpatches
import matplotlib.path as mpath

Path = mpath.Path

fig, ax = plt.subplots()
pp1 = mpatches.PathPatch(
    Path([(0, 0), (1, 0), (1, 1), (0, 0)],
         [Path.MOVETO, Path.CURVE3, Path.CURVE3, Path.CLOSEPOLY]),
    fc="none", transform=ax.transData)

ax.add_patch(pp1)
ax.plot([0.75], [0.25], "ro")
ax.set_title('The red point should be on the path')

plt.show()
The red point should be on the path

參考

此範例中顯示了以下函數、方法、類別和模組的使用方式

由 Sphinx-Gallery 產生的圖庫