code: def __init__(self, ax, data):
      # The information of whether a point has been selected or not is stored in the
      # collection's array (0 = out, 1 = in), which then gets colormapped to blue
      # (out) and red (in).
      self.collection = RegularPolyCollection(
          6,
          sizes=(100,),
          offset_transform=ax.transData,
          offsets=data,
          array=np.zeros(len(data)),
          clim=(0, 1),
          cmap=mcolors.ListedColormap(["tab:blue", "tab:red"]),
      )
      ax.add_collection(self.collection)
      canvas = ax.figure.canvas
      canvas.mpl_connect("button_press_event", self.on_press)
      canvas.mpl_connect("button_release_event", self.on_release)
  
file_path: matplotlib/galleries/examples/event_handling/lasso_demo.py
imports: import matplotlib.pyplot
  import numpy
  from matplotlib import colors
  from matplotlib import path
  from matplotlib.collections import RegularPolyCollection
  from matplotlib.widgets import Lasso
label_desc: Use image node_id 1 to create a new LassoManager object  with example: obj = LassoManager(ax, data)