The following is the explanation for the preceding code:
- on_move(event) is the callback function in response to the mouse move event:
- if event.inaxes checks whether the mouse move event happened within the axes or outside of them. If it was within the axes, then it executes the next set of instructions; otherwise, it does not.
- print() prints the coordinates, in the data coordinate system, of the point on the axes where the mouse was moving to sysout. You can see it in the output cell of your notebook.
- elapsed_time is the elapsed time from the beginning of the program till now. This is used to deactivate the move_event callback function, since the mouse move event generates a lot of sysout through print statements.
- if elapsed_time ...