- matplotlib.pyplot.connect(s, func)#
Bind function func to event s.
One of the following events ids:
The callback function to be executed, which must have the signature:
def func(event: Event) -> Any
For the location events (button and key press/release), if the mouse is over the Axes, the
inaxesattribute of the event will be set to the
Axesthe event occurs is over, and additionally, the variables
ydataattributes will be set to the mouse location in data coordinates. See
MouseEventfor more info.
A connection id that can be used with
def on_press(event): print('you pressed', event.button, event.xdata, event.ydata) cid = canvas.mpl_connect('button_press_event', on_press)