Event handling

We now have a good background for some practical work with matplotlib events. We are now ready to explore the nitty-gritty. Let's begin with the list of events that matplotlib supports:

Event name

Class

Description

button_press_event

MouseEvent

The mouse button is pressed

button_release_event

MouseEvent

The mouse button is released

draw_event

DrawEvent

The canvas draw occurs

key_press_event

KeyEvent

A key is pressed

key_release_event

KeyEvent

A key is released

motion_notify_event

MouseEvent

Motion of the mouse

pick_event

PickEvent

An object in the canvas is selected

resize_event

ResizeEvent

The figure canvas is resized

scroll_event

MouseEvent

The scroll wheel of the mouse is rolled

figure_enter_event ...

Get Mastering matplotlib now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.