def METHOD_NAME(event):
    if event.inaxes == ax:
        found = False
        for line in lines:
            cont, ind = line.contains(event)
            if cont:
                update_annot(line, ind)
                annot.set_visible(True)
                fig.canvas.draw_idle()
                found = True
                break
        if not found and annot.get_visible():
            annot.set_visible(False)
            fig.canvas.draw_idle()