add_picker

cb.add_picker(name, artist, picker)

Attach a custom picker to an artist.

Once attached, callbacks can be assigned just like the default click/pick callbacks via:

>>> m.cb.pick__<name>. ...
Parameters:
  • name (str, optional) – a unique identifier that will be used to identify the pick method.

  • artist (a matplotlib artist, optional) – the artist that should become pickable. (it must support artist.set_picker()) The default is None.

  • picker (callable, optional) –

    A callable that is used to perform the picking. The default is None, in which case the default picker is used. The call-signature is:

    >>> def picker(artist, mouseevent):
    >>>     # if the pick is NOT successful:
    >>>     return False, dict()
    >>>     ...
    >>>     # if the pick is successful:
    >>>     return True, dict(ID, pos, val, ind)
    

Note

If the name starts with an underscore (e.g. β€œ_MyPicker”) then the associated container will be accessible via m.cb._pick__MyPicker or via m.cb.pick[β€œ_MyPicker”]. (This is useful to setup pickers that are only used internally)