matplotlib.artist.Artist.set_picker

Artist.set_picker(self, picker)[source]

Define the picking behavior of the artist.

Parameters:
pickerNone or bool or callable

This can be one of the following:

  • None: Picking is disabled for this artist (default).

  • A boolean: If True then picking will be enabled and the artist will fire a pick event if the mouse event is over the artist.

  • A function: If picker is callable, it is a user supplied function which determines whether the artist is hit by the mouse event:

    hit, props = picker(artist, mouseevent)
    

    to determine the hit test. if the mouse event is over the artist, return hit=True and props is a dictionary of properties you want added to the PickEvent attributes.

  • deprecated: For Line2D only, picker can also be a float that sets the tolerance for checking whether an event occurred "on" the line; this is deprecated. Use Line2D.set_pickradius instead.