code: def test_plot():
      """Test TFR plotting."""
      data = np.zeros((3, 2, 3))
      times = np.array([0.1, 0.2, 0.3])
      freqs = np.array([0.10, 0.20])
      info = mne.create_info(
          ["MEG 001", "MEG 002", "MEG 003"],
          1000.0,
          ["mag", "mag", "mag"],
      )
      tfr = AverageTFR(
          info,
          data=data,
          times=times,
          freqs=freqs,
          nave=20,
          comment="test",
          method="crazy-tfr",
      )
  
      # test title=auto, combine=None, and correct length of figure list
      picks = [1, 2]
      figs = tfr.plot(
          picks,
          title="auto",
          colorbar=False,
          mask=np.ones(tfr.data.shape[1:], bool),
      )
      assert len(figs) == len(picks)
      assert "MEG" in figs[0].texts[0].get_text()
      plt.close("all")
  
      # test combine and title keyword
      figs = tfr.plot(
          picks,
          title="title",
          colorbar=False,
          combine="rms",
          mask=np.ones(tfr.data.shape[1:], bool),
      )
      assert len(figs) == 1
      assert figs[0].texts[0].get_text() == "title"
      figs = tfr.plot(
          picks,
          title="auto",
          colorbar=False,
          combine="mean",
          mask=np.ones(tfr.data.shape[1:], bool),
      )
      assert len(figs) == 1
      assert figs[0].texts[0].get_text() == "Mean of 2 sensors"
      figs = tfr.plot(
          picks,
          title="auto",
          colorbar=False,
          combine=lambda x: x.mean(axis=0),
          mask=np.ones(tfr.data.shape[1:], bool),
      )
      assert len(figs) == 1
  
      with pytest.raises(
          ValueError, match="Invalid value for the 'combine'"
      ):
          tfr.plot(
              picks,
              colorbar=False,
              combine="something",
              mask=np.ones(tfr.data.shape[1:], bool),
          )
      with pytest.raises(
          RuntimeError, match="must operate on a single"
      ):
          tfr.plot(picks, combine=lambda x, y: x.mean(axis=0))
      with pytest.raises(
          RuntimeError, match=re.escape("of shape (n_freqs, n_times).")
      ):
          tfr.plot(
              picks, combine=lambda x: x.mean(axis=0, keepdims=True)
          )
      with pytest.raises(
          RuntimeError,
          match=re.escape(
              "return a numpy array of shape (n_freqs, n_times)."
          ),
      ):
          tfr.plot(picks, combine=lambda x: 101)
  
      plt.close("all")
  
      # test axes argument - first with list of axes
      ax = plt.subplot2grid((2, 2), (0, 0))
      ax2 = plt.subplot2grid((2, 2), (0, 1))
      ax3 = plt.subplot2grid((2, 2), (1, 0))
      figs = tfr.plot(picks=[0, 1, 2], axes=[ax, ax2, ax3])
      assert len(figs) == len([ax, ax2, ax3])
      # and as a single axes
      figs = tfr.plot(picks=[0], axes=ax)
      assert len(figs) == 1
      plt.close("all")
      # and invalid inputs
      with pytest.raises(ValueError, match="axes must be None"):
          tfr.plot(
              picks,
              colorbar=False,
              axes={},
              mask=np.ones(tfr.data.shape[1:], bool),
          )
  
      # different number of axes and picks should throw a RuntimeError
      with pytest.raises(RuntimeError, match="There must be an axes"):
          tfr.plot(
              picks=[0],
              colorbar=False,
              axes=[ax, ax2],
              mask=np.ones(tfr.data.shape[1:], bool),
          )
  
      tfr.plot_topo(picks=[1, 2])
      plt.close("all")
  
      # interactive mode on by default
      fig = tfr.plot(picks=[1], cmap="RdBu_r")[0]
      _fake_keypress(fig, "up")
      _fake_keypress(fig, " ")
      _fake_keypress(fig, "down")
      _fake_keypress(fig, " ")
      _fake_keypress(fig, "+")
      _fake_keypress(fig, " ")
      _fake_keypress(fig, "-")
      _fake_keypress(fig, " ")
      _fake_keypress(fig, "pageup")
      _fake_keypress(fig, " ")
      _fake_keypress(fig, "pagedown")
  
      cbar = fig.get_axes()[0].CB  # Fake dragging with mouse.
      ax = cbar.cbar.ax
      _fake_click(fig, ax, (0.1, 0.1))
      _fake_click(fig, ax, (0.1, 0.2), kind="motion")
      _fake_click(fig, ax, (0.1, 0.3), kind="release")
  
      _fake_click(fig, ax, (0.1, 0.1), button=3)
      _fake_click(fig, ax, (0.1, 0.2), button=3, kind="motion")
      _fake_click(fig, ax, (0.1, 0.3), kind="release")
  
      _fake_scroll(fig, 0.5, 0.5, -0.5)  # scroll down
      _fake_scroll(fig, 0.5, 0.5, 0.5)  # scroll up
  
      plt.close("all")
  
imports: import datetime
  import re
  from itertools import product
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from scipy.signal import morlet2
  import mne
  from mne import Epochs, EpochsArray, Info, Transform, create_info, pick_types, read_events
  from mne.io import read_raw_fif
  from mne.tests.test_epochs import assert_metadata_equal
  from mne.time_frequency import tfr_array_morlet, tfr_array_multitaper
  from mne.time_frequency.tfr import AverageTFR, EpochsTFR, _compute_tfr, _make_dpss, combine_tfr, cwt, fwhm, morlet, read_tfrs, tfr_morlet, tfr_multitaper, write_tfrs
  from mne.utils import catch_logging, grand_average
  from mne.viz.utils import _fake_click, _fake_keypress, _fake_scroll
label_desc: Use image node_id 11 for calling a global function with example usage: test_plot() without return types