code: def test_plot_topo():
      """Test plotting of ERP topography."""
      # Show topography
      evoked = _get_epochs().average()
      # should auto-find layout
      plot_evoked_topo(
          [evoked, evoked], merge_grads=True, background_color="w"
      )
  
      plot_evoked_topo(
          [evoked, evoked],
          merge_grads=True,
          background_color="w",
          color="blue",
      )
  
      # test legend colors
      colors = ["red", "blue"]
      fig = plot_evoked_topo(
          [evoked, evoked], merge_grads=True, color=colors
      )
      legend = fig.axes[0].get_legend()
      legend_colors = [
          line.properties()["markeredgecolor"]
          for line in legend.get_lines()
      ]
      assert legend_colors == colors
  
      with pytest.raises(
          ValueError, match="must be .*tuple, list, str,.*"
      ):
          plot_evoked_topo(
              [evoked, evoked],
              merge_grads=True,
              color=np.array(["blue", "red"]),
          )
  
      picked_evoked = evoked.copy().pick(evoked.ch_names[:3])
      picked_evoked_eeg = evoked.copy().pick(picks="eeg")
      picked_evoked_eeg.pick(picked_evoked_eeg.ch_names[:3])
  
      # test scaling
      for ylim in [dict(mag=[-600, 600]), None]:
          plot_evoked_topo([picked_evoked] * 2, layout, ylim=ylim)
  
      for evo in [evoked, [evoked, picked_evoked]]:
          pytest.raises(
              ValueError,
              plot_evoked_topo,
              evo,
              layout,
              color=["y", "b"],
          )
  
      evoked_delayed_ssp = _get_epochs_delayed_ssp().average()
      ch_names = evoked_delayed_ssp.ch_names[:3]  # make it faster
      picked_evoked_delayed_ssp = evoked_delayed_ssp.pick(ch_names)
      fig = plot_evoked_topo(
          picked_evoked_delayed_ssp, layout, proj="interactive"
      )
      func = _get_presser(fig)
      event = namedtuple("Event", ["inaxes", "xdata", "ydata"])
      func(
          event(
              inaxes=fig.axes[0],
              xdata=fig.axes[0]._mne_axs[0].pos[0],
              ydata=fig.axes[0]._mne_axs[0].pos[1],
          )
      )
      func(event(inaxes=fig.axes[0], xdata=0, ydata=0))
      params = dict(
          evokeds=[picked_evoked_delayed_ssp],
          times=picked_evoked_delayed_ssp.times,
          fig=fig,
          projs=picked_evoked_delayed_ssp.info["projs"],
      )
      bools = [True] * len(params["projs"])
      with pytest.warns(RuntimeWarning, match="projection"):
          _plot_update_evoked_topo_proj(params, bools)
  
      # should auto-generate layout
      plot_evoked_topo(
          picked_evoked_eeg.copy(),
          fig_background=np.zeros((4, 3, 3)),
          proj=True,
          background_color="k",
      )
      # Test RMS plot of grad pairs
      picked_evoked.plot_topo(merge_grads=True, background_color="w")
      plt.close("all")
      for ax, idx in iter_topography(evoked.info, legend=True):
          ax.plot(evoked.data[idx], color="red")
          # test status bar message
          if idx != -1:
              assert evoked.ch_names[idx] in ax.format_coord(0.5, 0.5)
      assert idx == -1
      plt.close("all")
      cov = read_cov(cov_fname)
      cov["projs"] = []
      evoked.pick(picks="meg").plot_topo(noise_cov=cov)
      plt.close("all")
  
      # Test exclude parameter
      exclude = ["MEG 0112"]
      fig = picked_evoked.plot_topo(exclude=exclude)
      n_axes_expected = len(picked_evoked.info["ch_names"]) - len(
          exclude
      )
      n_axes_found = len(fig.axes[0].lines)
      assert n_axes_found == n_axes_expected
  
      # test plot_topo
      evoked.plot_topo()  # should auto-find layout
      _line_plot_onselect(
          0,
          200,
          ["mag", "grad"],
          evoked.info,
          evoked.data,
          evoked.times,
      )
      plt.close("all")
  
      for ax, idx in iter_topography(
          evoked.info
      ):  # brief test with false
          ax.plot([0, 1, 2])
          break
      plt.close("all")
  
imports: from collections import namedtuple
  from pathlib import Path
  import matplotlib
  import matplotlib.pyplot
  import numpy
  import pytest
  from mne import Epochs, compute_proj_evoked, read_cov, read_events
  from mne.channels import read_layout
  from mne.io import read_raw_fif
  from mne.time_frequency.tfr import AverageTFR
  from mne.utils import _record_warnings
  from mne.viz import _get_presser, mne_analyze_colormap, plot_evoked_topo, plot_topo_image_epochs
  from mne.viz.evoked import _line_plot_onselect
  from mne.viz.topo import _imshow_tfr, _plot_update_evoked_topo_proj, iter_topography
  from mne.viz.utils import _fake_click
label_desc: Use image node_id 6 for calling a global function with example usage: test_plot_topo() without return types