Registers a function to be run when a key is pressed in a Matplotlib visualizer.
fn will run if
key is pressed at any time when the plot window is in focus. To narrow the focus to a particular plot, define
catchKeypress() in a subclass of
key — str, required
The key to listen for. The string must be one character; other strings, or strings not corresponding to a single key, will be ignored.
fn — func(model, event), required
A function to run when
keyis pressed in the Matplotlib visualization.
modelis the model object, and
eventis the Matplotlib event object.
Notes and Examples
charwickFeb 03, 2021 at 21:31
When modifying the visualization after a keypress, always access the figure through
event.canvas.figureand not through
model.visual.fig. The former will correctly route the event to the currently open figure, whereas the latter will route the event to the figure corresponding to the currently active model, even if the key was pressed in the window of a terminated model.