code: def test_plot_source_estimates(
      renderer_interactive,
      all_src_types_inv_evoked,
      pick_ori,
      kind,
      brain_gc,
  ):
      """Test plotting of scalar and vector source estimates."""
      backend = renderer_interactive._get_3d_backend()
      invs, evoked = all_src_types_inv_evoked
      inv = invs[kind]
      with _record_warnings():  # PCA mag
          stc = apply_inverse(evoked, inv, pick_ori=pick_ori)
      stc.data[1] *= -1  # make it signed
      meth_key = (
          "plot_3d"
          if isinstance(stc, _BaseVolSourceEstimate)
          else "plot"
      )
      stc.subject = "sample"
      meth = getattr(stc, meth_key)
      kwargs = dict(
          subjects_dir=subjects_dir,
          time_viewer=False,
          show_traces=False,  # for speed
          smoothing_steps=1,
          verbose="error",
          src=inv["src"],
          volume_options=dict(resolution=None),  # for speed
      )
      if pick_ori != "vector":
          kwargs["surface"] = "white"
          kwargs["backend"] = backend
      brain = meth(**kwargs)
      brain.close()
      del brain
  
      these_kwargs = kwargs.copy()
      these_kwargs["show_traces"] = "foo"
      with pytest.raises(ValueError, match="show_traces"):
          meth(**these_kwargs)
      del these_kwargs
      if pick_ori == "vector":
          with pytest.raises(ValueError, match='use "pos_lims"'):
              meth(**kwargs, clim=dict(pos_lims=[1, 2, 3]))
      if kind in ("volume", "mixed"):
          with pytest.raises(
              TypeError, match="when stc is a mixed or vol"
          ):
              these_kwargs = kwargs.copy()
              these_kwargs.pop("src")
              meth(**these_kwargs)
  
      with pytest.raises(ValueError, match="cannot be used"):
          these_kwargs = kwargs.copy()
          these_kwargs.update(show_traces=True, time_viewer=False)
          meth(**these_kwargs)
  
      # flatmaps (mostly a lot of error checking)
      these_kwargs = kwargs.copy()
      these_kwargs.update(
          surface="flat", views="auto", hemi="both", verbose="debug"
      )
      if kind == "surface" and pick_ori != "vector":
          with catch_logging() as log:
              with pytest.raises(FileNotFoundError, match="flatmap"):
                  meth(**these_kwargs)  # sample does not have them
          log = log.getvalue()
          assert "offset: 0" in log
      fs_stc = stc.copy()
      fs_stc.subject = (
          "fsaverage"  # this is wrong, but don't have to care
      )
      flat_meth = getattr(fs_stc, meth_key)
      these_kwargs.pop("src")
      if pick_ori == "vector":
          pass  # can't even pass "surface" variable
      elif kind != "surface":
          with pytest.raises(
              TypeError, match="SourceEstimate when a flatmap"
          ):
              flat_meth(**these_kwargs)
      else:
          brain = flat_meth(**these_kwargs)
          brain.close()
          del brain
          these_kwargs.update(surface="inflated", views="flat")
          with pytest.raises(
              ValueError, match='surface="flat".*views="flat"'
          ):
              flat_meth(**these_kwargs)
  
      # just test one for speed
      if kind != "mixed":
          return
      brain = meth(
          views=["lat", "med", "ven"],
          hemi="lh",
          view_layout="horizontal",
          **kwargs,
      )
      brain.close()
      assert brain._subplot_shape == (1, 3)
      del brain
      these_kwargs = kwargs.copy()
      these_kwargs["volume_options"] = dict(blending="foo")
      with pytest.raises(ValueError, match="mip"):
          meth(**these_kwargs)
      these_kwargs["volume_options"] = dict(badkey="foo")
      with pytest.raises(ValueError, match="unknown"):
          meth(**these_kwargs)
      # with resampling (actually downsampling but it's okay)
      these_kwargs["volume_options"] = dict(
          resolution=20.0, surface_alpha=0.0
      )
      brain = meth(**these_kwargs)
      brain.close()
      del brain
  
imports: from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from matplotlib.colors import Colormap
  from matplotlib.figure import Figure
  from numpy.testing import assert_allclose, assert_array_equal
  from mne import MixedSourceEstimate, SourceEstimate, convert_forward_solution, make_field_map, make_sphere_model, pick_info, pick_types, read_dipole, read_evokeds, read_forward_solution, read_trans, setup_volume_source_space, use_coil_def
  from mne._fiff._digitization import write_dig
  from mne._fiff.constants import FIFF
  from mne.bem import read_bem_solution, read_bem_surfaces
  from mne.datasets import testing
  from mne.defaults import DEFAULTS
  from mne.io import read_info, read_raw_bti, read_raw_ctf, read_raw_kit, read_raw_nirx
  from mne.minimum_norm import apply_inverse
  from mne.source_estimate import _BaseVolSourceEstimate
  from mne.source_space import read_source_spaces
  from mne.transforms import Transform
  from mne.utils import _record_warnings, catch_logging
  from mne.viz import Brain, EvokedField, Figure3D, link_brains, mne_analyze_colormap, plot_alignment, plot_brain_colorbar, plot_head_positions, plot_source_estimates, plot_sparse_source_estimates, snapshot_brain_montage
  from mne.viz._3d import _get_map_ticks, _linearize_map, _process_clim
  from mne.viz.utils import _fake_click, _fake_keypress, _fake_scroll, _get_cmap
label_desc: Use image node_id 18 for calling a global function with example usage: test_plot_source_estimates(renderer_interactive, all_src_types_inv_evoked, pick_ori, kind, brain_gc) without return types