class_docstr: A polygon editor.
  
  Key-bindings
  
    't' toggle vertex markers on and off.  When vertex markers are on,
        you can move them, delete them
  
    'd' delete the vertex under point
  
    'i' insert a vertex at point.  You must be within epsilon of the
        line connecting two existing vertices
class_docstr_tok: ["A","polygon","editor",".","Key-bindings","'t","'","toggle","vertex","markers","on","and","off",".","When","vertex","markers","are","on",",","you","can","move","them",",","delete","them","'d","'","delete","the","vertex","under","point","'","i","'","insert","a","vertex","at","point",".","You","must","be","within","epsilon","of","the","line","connecting","two","existing","vertices"]
code: def __init__(self, ax, poly):
      if poly.figure is None:
          raise RuntimeError(
              "You must first add the polygon to a figure "
              "or canvas before defining the interactor"
          )
      self.ax = ax
      canvas = poly.figure.canvas
      self.poly = poly
  
      x, y = zip(*self.poly.xy)
      self.line = Line2D(
          x, y, marker="o", markerfacecolor="r", animated=True
      )
      self.ax.add_line(self.line)
  
      self.cid = self.poly.add_callback(self.poly_changed)
      self._ind = None  # the active vert
  
      canvas.mpl_connect("draw_event", self.on_draw)
      canvas.mpl_connect("button_press_event", self.on_button_press)
      canvas.mpl_connect("key_press_event", self.on_key_press)
      canvas.mpl_connect("button_release_event", self.on_button_release)
      canvas.mpl_connect("motion_notify_event", self.on_mouse_move)
      self.canvas = canvas
  
file_path: matplotlib/galleries/examples/event_handling/poly_editor.py
imports: import numpy
  from matplotlib.artist import Artist
  from matplotlib.lines import Line2D
label_desc: Use image node_id 1 to create a new PolygonInteractor object  with example: obj = PolygonInteractor(ax, poly)