我需要绘制一个有四条边的多边形,其中右侧是一段弧线。类似于下面这个图示:
我尝试使用matplotlib提供的贝塞尔曲线代码,但没有成功。希望能得到帮助:)
from matplotlib.path import Path
import matplotlib.patches as patches
verts = [
(0., 0.), # P0
(0, 1.), # P1
(1., 1), # P2
(1, 0.), # P3
]
codes = [
Path.MOVETO,
Path.CURVE4,
Path.CURVE4,
Path.CURVE4,
]
path = Path(verts, codes)
fig, ax = plt.subplots()
patch = patches.PathPatch(path, facecolor='none', lw=2)
ax.add_patch(patch)
xs, ys = zip(*verts)
ax.plot(xs, ys, lw=2, color='black', ms=10)
ax.set_xlim(-0.1, 1.1)
ax.set_ylim(-0.1, 1.1)
plt.show()