Annotate lines of a plot with matplotlib when hover with mouse [duplicate]
问题 This question already has answers here : Possible to make labels appear when hovering over a point in matplotlib? (10 answers) Closed 1 year ago . I want to annotate different lines on a plot when hovering with the mouse, the same way is done here with points Possible to make labels appear when hovering over a point in matplotlib? I tried to adapt this code as the following : import matplotlib.pyplot as plt import numpy as np; np.random.seed(1) y = np.random.rand(4,15) x = [np.arange(15) for