Chapter 2. Using Events and Callbacks
Wait time is the worst I can hardly sit No one has the time Someone is always late | ||
--The Strokes, Call Me Back (2011) |
The callback system in Matplotlib is central to its interactivity. Unless you are working with the interactive plotting mode on, execution of the script stops when plt.show()
is called. Without the ability to execute any additional code, the only way to program interactivity is to register actions to be taken upon some event such as a button click, mouse cursor motion, or key press. Matplotlib's callback system has a base set of events and many callbacks that we have already discussed, such as the default keymap discussed in the previous chapter and the ability to pan a plot. Furthermore, it is possible to add new kinds of events, giving the developer full access to Matplotlib's cross-platform callback system.