matplotlib.artist.Artist.set_picker#

Artist.set_picker(picker)[source]#

Define the picking behavior of the artist.

Parameters:
pickerNone or bool or float or callable

This can be one of the following:

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

  • A boolean: IfTrue then picking will be enabled and theartist will fire a pick event if the mouse event is overthe artist.

  • A float: If picker is a number it is interpreted as anepsilon tolerance in points and the artist will fireoff an event if its data is within epsilon of the mouseevent. For some artists like lines and patch collections,the artist may provide additional data to the pick eventthat is generated, e.g., the indices of the data withinepsilon of the pick event

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

    hit,props=picker(artist,mouseevent)

    to determine the hit test. if the mouse event is over theartist, returnhit=True and props is a dictionary ofproperties you want added to the PickEvent attributes.

Examples usingmatplotlib.artist.Artist.set_picker#

Legend picking

Legend picking

Pick event demo

Pick event demo