Show channle's name when clicking on the line

Hi, I want to plot a multi-channel signal’s PSD.
I hope the figure will show the name of the channel where my mouse clicked.
Here is a screenshot of the figure.

Anyone knows how to do this using

fig.canvas.mpl_connect('button_press_event', funcs)

To be specific, how do I write my funcs?

It depends somewhat on how you added the lines, but you probably want to follow the Object picking guide:
https://matplotlib.org/stable/users/explain/event_handling.html#object-picking

You may also want to try mplcursors:
https://mplcursors.readthedocs.io/en/stable/

1 Like