

def _butterfly_onpick(event, params):
    'Helper to add a channel name on click'
    params['need_draw'] = True
    ax = event.artist.get_axes()
    ax_idx = np.where([(ax is a) for a in params['axes']])[0]
    if (len(ax_idx) == 0):
        return
    else:
        ax_idx = ax_idx[0]
    lidx = np.where([(l is event.artist) for l in params['lines'][ax_idx]])[0][0]
    ch_name = params['ch_names'][params['idxs'][ax_idx][lidx]]
    text = params['texts'][ax_idx]
    x = event.artist.get_xdata()[event.ind[0]]
    y = event.artist.get_ydata()[event.ind[0]]
    text.set_x(x)
    text.set_y(y)
    text.set_text(ch_name)
    text.set_color(event.artist.get_color())
    text.set_alpha(1.0)
    text.set_path_effects(params['path_effects'])

dataset/ETHPy150Open mne-tools/mne-python/mne/viz/evoked.py _butterfly_onpick/original