An event handling method that can be overridden in subclasses to catch pick (pick_event
), keypress (key_press_event
), and mouse click (button_press_event
) events that occur inside a particular plot. This is distinct from functions passed to MPLVisualization.addKeypress()
, as those will run for keys pressed any time the visualization window is in focus, regardless of the mouse position.
For example, pressing ‘l’ with the mouse over a AgentsPlot
will rotate the layout. The key pressed can be accessed with event.key
.
This function should not be called by user code, but it may be defined in subclasses of ChartPlot
. event.canvas.draw_idle()
should be called at the end if the plot needs to be refreshed following the event. See the Matplotlib events documentation for more on interacting with the event
object.
Parameters
event — matplotlib.Event, required
charwick
Jun 14, 2021 at 23:59This function can handle multiple types of events, which can be distinguished with
event.name
. This example handles three types of events in aAgentsPlot
:Artist
representing an agent is clicked on) to identify theAgent
object of the clickedArtist
and pass it to a hook, andPatch
object underneath the clicked coordinates and pass it to a hook.