code: def on_pick(event):
      # On the pick event, find the original line corresponding to the legend
      # proxy line, and toggle its visibility.
      legend_line = event.artist
  
      # Do nothing if the source of the event is not a legend line.
      if legend_line not in map_legend_to_ax:
          return
  
      ax_line = map_legend_to_ax[legend_line]
      visible = not ax_line.get_visible()
      ax_line.set_visible(visible)
      # Change the alpha on the line in the legend, so we can see what lines
      # have been toggled.
      legend_line.set_alpha(1.0 if visible else 0.2)
      fig.canvas.draw()
  
label_desc: Use image node_id 1 for calling a global function with example usage: on_pick(event) without return types