matplotlib.patch
对象底层的对象就是Path
。它的基本用法如下:
import matplotlib.pyplot as plt from matplotlib.path import Path import matplotlib.patches as patches verts = [ (0., 0.), # left, bottom (0., 1.), # left, top (1., 1.), # right, top (1., 0.), # right, bottom (0., 0.), # ignored ] codes = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY, ] path = Path(verts, codes) fig = plt.figure() ax = fig.add_subplot(111) patch = patches.PathPatch(path) ax.add_patch(patch) ax.set_xlim(-2, 2) ax.set_ylim(-2, 2) plt.show()
原文:https://www.cnblogs.com/nxf-rabbit75/p/12099127.html