def _butterfly_onpick(event, params):
 params['need_draw'] = True
 ax = event.artist.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_zorder(len(ax.lines))
 text.set_path_effects(params['path_effects'])

def _butterfly_onpick ( event , params ) : params [ 'need_draw' ] = True ax = event . artist . 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_zorder ( len ( ax . lines ) ) text . set_path_effects ( params [ 'path_effects' ] )
add a channel name on click .