Skip to content

Instantly share code, notes, and snippets.

@sabopy
Last active July 23, 2020 12:19
Show Gist options
  • Save sabopy/2711385d68707c3b2467309381c3e4f0 to your computer and use it in GitHub Desktop.
Save sabopy/2711385d68707c3b2467309381c3e4f0 to your computer and use it in GitHub Desktop.
import matplotlib.path as mpath
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
Path = mpath.Path
fig, ax = plt.subplots()
pp1 = mpatches.PathPatch(
Path([(0, 0), (1, 0), (1, 1)],
[Path.MOVETO, Path.CURVE3, Path.CURVE3]),
fc="C2", transform=ax.transData,alpha=0.5)
ax.add_patch(pp1)
ax.plot([0,1], [0,1], "ro")
ax.set_title('Quadratic Bézier curve')
plt.savefig("quadbc.png",dpi=120)
plt.show()
fig, ax = plt.subplots()
pp1 = mpatches.PathPatch(
Path([(0, 0), (1, 0), (1, 1), (0, 1)],
[Path.MOVETO, Path.CURVE4, Path.CURVE4, Path.CURVE4]),
fc="C6", transform=ax.transData,alpha=0.5)
ax.add_patch(pp1)
ax.plot([0,0], [0,1], "ro")
ax.set_title('Cubic Bézier curve')
plt.savefig("cubicbc.png",dpi=120)
plt.show()
import matplotlib
print(matplotlib.__version__)
3.2.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment