code: def _line_plot_onselect(
      xmin,
      xmax,
      ch_types,
      info,
      data,
      times,
      text=None,
      psd=False,
      time_unit="s",
      sphere=None,
  ):
      """Draw topomaps from the selected area."""
      import matplotlib.pyplot as plt
  
      from ..channels.layout import _pair_grad_sensors
  
      ch_types = [
          type_ for type_ in ch_types if type_ in ("eeg", "grad", "mag")
      ]
      if len(ch_types) == 0:
          raise ValueError(
              "Interactive topomaps only allowed for EEG "
              "and MEG channels."
          )
      if (
          "grad" in ch_types
          and len(
              _pair_grad_sensors(
                  info, topomap_coords=False, raise_error=False
              )
          )
          < 2
      ):
          ch_types.remove("grad")
          if len(ch_types) == 0:
              return
  
      vert_lines = list()
      if text is not None:
          text.set_visible(True)
          ax = text.axes
          vert_lines.append(ax.axvline(xmin, zorder=0, color="red"))
          vert_lines.append(ax.axvline(xmax, zorder=0, color="red"))
          fill = ax.axvspan(xmin, xmax, alpha=0.2, color="green")
          evoked_fig = plt.gcf()
          evoked_fig.canvas.draw()
          evoked_fig.canvas.flush_events()
  
      minidx = np.abs(times - xmin).argmin()
      maxidx = np.abs(times - xmax).argmin()
      fig, axarr = plt.subplots(
          1,
          len(ch_types),
          squeeze=False,
          figsize=(3 * len(ch_types), 3),
          layout="constrained",
      )
  
      for idx, ch_type in enumerate(ch_types):
          if ch_type not in ("eeg", "grad", "mag"):
              continue
          (
              picks,
              pos,
              merge_channels,
              _,
              ch_type,
              this_sphere,
              clip_origin,
          ) = _prepare_topomap_plot(info, ch_type, sphere=sphere)
          outlines = _make_head_outlines(
              this_sphere, pos, "head", clip_origin
          )
          if len(pos) < 2:
              fig.delaxes(axarr[0][idx])
              continue
          this_data = data[picks, minidx:maxidx]
          if merge_channels:
              from ..channels.layout import _merge_ch_data
  
              method = "mean" if psd else "rms"
              this_data, _ = _merge_ch_data(
                  this_data, ch_type, [], method=method
              )
              title = "%s %s" % (ch_type, method.upper())
          else:
              title = ch_type
          this_data = np.average(this_data, axis=1)
          axarr[0][idx].set_title(title)
          # can be all negative for dB PSD
          vlim = (
              (min(this_data), max(this_data)) if psd else (None, None)
          )
          cmap = "Reds" if psd else None
          plot_topomap(
              this_data,
              pos,
              cmap=cmap,
              vlim=vlim,
              axes=axarr[0][idx],
              show=False,
              sphere=this_sphere,
              outlines=outlines,
          )
  
      unit = "Hz" if psd else time_unit
      fig.suptitle(
          "Average over %.2f%s - %.2f%s" % (xmin, unit, xmax, unit),
          y=0.1,
      )
      plt_show()
      if text is not None:
          text.set_visible(False)
          close_callback = partial(
              _topo_closed, ax=ax, lines=vert_lines, fill=fill
          )
          fig.canvas.mpl_connect("close_event", close_callback)
          evoked_fig.canvas.draw()
          evoked_fig.canvas.flush_events()
  
imports: from copy import deepcopy
  from functools import partial
  from itertools import cycle
  from numbers import Integral
  import numpy
  from .._fiff.pick import _DATA_CH_TYPES_SPLIT, _PICK_TYPES_DATA_DICT, _VALID_CHANNEL_TYPES, _picks_to_idx, channel_indices_by_type, channel_type, pick_info
  from ..defaults import _handle_default
  from ..fixes import _is_last_row
  from ..utils import _check_ch_locs, _check_if_nan, _clean_names, _is_numeric, _pl, _to_rgb, _validate_type, fill_doc, logger, verbose, warn
  from .topo import _plot_evoked_topo
  from .topomap import _check_sphere, _draw_outlines, _get_pos_outlines, _make_head_outlines, _prepare_topomap, _prepare_topomap_plot, _set_contour_locator, plot_topomap
  from .utils import DraggableColorbar, _check_cov, _check_delayed_ssp, _check_option, _check_time_unit, _draw_proj_checkbox, _get_cmap, _get_color_list, _make_combine_callable, _plot_masked_image, _prepare_joint_axes, _process_times, _prop_kw, _set_title_multiple_electrodes, _set_window_title, _setup_ax_spines, _setup_cmap, _setup_plot_projector, _setup_vmin_vmax, _triage_rank_sss, _trim_ticks, _validate_if_list_of_axes, plt_show
label_desc: Use image node_id 3 for calling a global function with example usage: _line_plot_onselect(xmin, xmax, ch_types, info, data, times, text, psd, time_unit, sphere) without return types