Complete the code to import the module needed for plotting.
import [1] as plt
We use matplotlib.pyplot for plotting graphs and handling cursor events.
Complete the code to create a figure and axis for plotting.
fig, ax = plt.[1]()The subplots() function creates a figure and axes for plotting.
Fix the error in the event connection code to correctly connect the cursor move event.
cid = fig.canvas.[1]('motion_notify_event', on_move)
The correct method to connect events in matplotlib is connect.
Fill both blanks to create a cursor object and enable it on the axis.
cursor = Cursor([1], useblit=True, color='red', linewidth=1) cursor.[2]()
The cursor is created on the axis ax and draw() is called to enable it.
Fill all three blanks to create a function that prints cursor coordinates on mouse move.
def on_move(event): if event.inaxes == [1]: x, y = event.[2], event.[3] print(f"Cursor at: ({x:.2f}, {y:.2f})")
The event's inaxes is compared to ax. Coordinates are accessed via xdata and ydata.
