code: def plot_cov(
      cov,
      info,
      exclude=(),
      colorbar=True,
      proj=False,
      show_svd=True,
      show=True,
      verbose=None,
  ):
      """Plot Covariance data.
  
      Parameters
      ----------
      cov : instance of Covariance
          The covariance matrix.
      %(info_not_none)s
      exclude : list of str | str
          List of channels to exclude. If empty do not exclude any channel.
          If 'bads', exclude info['bads'].
      colorbar : bool
          Show colorbar or not.
      proj : bool
          Apply projections or not.
      show_svd : bool
          Plot also singular values of the noise covariance for each sensor
          type. We show square roots ie. standard deviations.
      show : bool
          Show figure if True.
      %(verbose)s
  
      Returns
      -------
      fig_cov : instance of matplotlib.figure.Figure
          The covariance plot.
      fig_svd : instance of matplotlib.figure.Figure | None
          The SVD spectra plot of the covariance.
  
      See Also
      --------
      mne.compute_rank
  
      Notes
      -----
      For each channel type, the rank is estimated using
      :func:`mne.compute_rank`.
  
      .. versionchanged:: 0.19
         Approximate ranks for each channel type are shown with red dashed lines.
      """
      import matplotlib.pyplot as plt
      from matplotlib.colors import Normalize
  
      from ..cov import Covariance
  
      info, C, ch_names, idx_names = _index_info_cov(info, cov, exclude)
      del cov, exclude
  
      projs = []
      if proj:
          projs = copy.deepcopy(info["projs"])
  
          #   Activate the projection items
          for p in projs:
              p["active"] = True
  
          P, ncomp, _ = make_projector(projs, ch_names)
          if ncomp > 0:
              logger.info(
                  "    Created an SSP operator (subspace dimension"
                  " = %d)" % ncomp
              )
              C = np.dot(P, np.dot(C, P.T))
          else:
              logger.info(
                  "    The projection vectors do not apply to these "
                  "channels."
              )
  
      if np.iscomplexobj(C):
          C = np.sqrt((C * C.conj()).real)
  
      fig_cov, axes = plt.subplots(
          1,
          len(idx_names),
          squeeze=False,
          figsize=(3.8 * len(idx_names), 3.7),
          layout="constrained",
      )
      for k, (idx, name, _, _, _) in enumerate(idx_names):
          vlim = np.max(np.abs(C[idx][:, idx]))
          im = axes[0, k].imshow(
              C[idx][:, idx],
              interpolation="nearest",
              norm=Normalize(vmin=-vlim, vmax=vlim),
              cmap="RdBu_r",
          )
          axes[0, k].set(title=name)
  
          if colorbar:
              from mpl_toolkits.axes_grid1 import make_axes_locatable
  
              divider = make_axes_locatable(axes[0, k])
              cax = divider.append_axes("right", size="5.5%", pad=0.05)
              cax.grid(False)  # avoid mpl warning about auto-removal
              plt.colorbar(im, cax=cax, format="%.0e")
  
      fig_svd = None
      if show_svd:
          fig_svd, axes = plt.subplots(
              1,
              len(idx_names),
              squeeze=False,
              figsize=(3.8 * len(idx_names), 3.7),
              layout="constrained",
          )
          for k, (idx, name, unit, scaling, key) in enumerate(
              idx_names
          ):
              this_C = C[idx][:, idx]
              s = _safe_svd(this_C, compute_uv=False)
              this_C = Covariance(
                  this_C,
                  [info["ch_names"][ii] for ii in idx],
                  [],
                  [],
                  0,
              )
              this_info = pick_info(info, idx)
              with this_info._unlock():
                  this_info["projs"] = []
              this_rank = compute_rank(this_C, info=this_info)
              # Protect against true zero singular values
              s[s <= 0] = 1e-10 * s[s > 0].min()
              s = np.sqrt(s) * scaling
              axes[0, k].plot(s, color="k", zorder=3)
              this_rank = this_rank[key]
              axes[0, k].axvline(
                  this_rank - 1,
                  ls="--",
                  color="r",
                  alpha=0.5,
                  zorder=4,
                  clip_on=False,
              )
              axes[0, k].text(
                  this_rank - 1,
                  axes[0, k].get_ylim()[1],
                  "rank ≈ %d" % (this_rank,),
                  ha="right",
                  va="top",
                  color="r",
                  alpha=0.5,
                  zorder=4,
              )
              axes[0, k].set(
                  ylabel="Noise σ (%s)" % unit,
                  yscale="log",
                  xlabel="Eigenvalue index",
                  title=name,
                  xlim=[0, len(s) - 1],
              )
  
      plt_show(show)
      return fig_cov, fig_svd
  
imports: import copy
  import io
  import os
  import os.path
  import warnings
  from collections import defaultdict
  from glob import glob
  from itertools import cycle
  from pathlib import Path
  import numpy
  from scipy.signal import filtfilt, freqz, group_delay, lfilter, sosfilt, sosfiltfilt
  from .._fiff.constants import FIFF
  from .._fiff.pick import _DATA_CH_TYPES_SPLIT, _picks_by_type, pick_channels, pick_info, pick_types
  from .._fiff.proj import make_projector
  from .._freesurfer import _check_mri, _mri_orientation, _read_mri_info, _reorient_image
  from ..defaults import DEFAULTS
  from ..filter import estimate_ringing_samples
  from ..fixes import _safe_svd
  from ..rank import compute_rank
  from ..surface import read_surface
  from ..transforms import _frame_to_str, apply_trans
  from ..utils import _check_option, _mask_to_onsets_offsets, _on_missing, _pl, fill_doc, get_subjects_dir, logger, verbose, warn
  from .utils import _figure_agg, _get_color_list, _prepare_trellis, _validate_type, plt_show
label_desc: Use image node_id 2 for calling a global function with example usage: plot_cov(cov, info, exclude, colorbar, proj, show_svd, show, verbose) and returns: fig_cov,  fig_svd