Picking
We demonstrated pick events earlier, showing how to select a storm track, changing its thickness, but we haven't incorporated picking into our current design yet. Much in the same vein as the KeymapControl
class, let's create a PickControl
class that will keep a list of pick functions (pickers) and manage their connection to the callback system for us:
Source: chp2/select_stormcells.py
class PickControl: def __init__(self, fig): self.fig = fig self._pickers = [] self._pickcids = [] def connect_picks(self): for i, picker in enumerate(self._pickers): if self._pickcids[i] is None: cid = self.fig.canvas.mpl_connect('pick_event', picker) self._pickcids[i] = cid def disconnect_picks(self): for i, cid in enumerate(self._pickcids): if cid is not None: self.fig.canvas.mpl_disconnect(cid) self._pickcids[i] = None def add_pick_action...