课程评价 (0)

请对课程作出评价:
0/300

学员评价

暂无精选评价
10分钟

Path

  1. 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()