code: def _plot_anat(
      slicer,
      anat,
      anat_affine,
      title=None,
      annotate=True,
      draw_cross=True,
      dim=False,
      cmap=plt.cm.gray,
      **imshow_kwargs,
  ):
      """Internal function used to plot anatomy"""
      canonical_anat = False
      if anat is None:
          try:
              anat, anat_affine, vmax_anat = _AnatCache.get_anat()
              canonical_anat = True
          except OSError as e:
              anat = False
              warnings.warn(repr(e))
  
      black_bg = slicer._black_bg
      # XXX: Check that we should indeed plot an anat: we have one, and the
      # cut_coords are in its range
  
      if anat is not False:
          if canonical_anat:
              # We special-case the 'canonical anat', as we don't need
              # to do a few transforms to it.
              vmin = 0
              vmax = vmax_anat
          elif dim:
              vmin = anat.min()
              vmax = anat.max()
          else:
              vmin = None
              vmax = None
              anat, anat_affine = _xyz_order(anat, anat_affine)
          if dim:
              vmean = 0.5 * (vmin + vmax)
              ptp = 0.5 * (vmax - vmin)
              if not is_numlike(dim):
                  dim = 0.6
              if black_bg:
                  vmax = vmean + (1 + dim) * ptp
              else:
                  vmin = vmean - (1 + dim) * ptp
          slicer.plot_map(
              anat,
              anat_affine,
              cmap=cmap,
              vmin=vmin,
              vmax=vmax,
              **imshow_kwargs,
          )
  
          if annotate:
              slicer.annotate()
          if draw_cross:
              slicer.draw_cross()
  
      if black_bg:
          # To have a black background in PDF, we need to create a
          # patch in black for the background
          for ax in slicer.axes.values():
              ax.ax.imshow(
                  np.zeros((2, 2, 3)),
                  extent=[-5000, 5000, -5000, 5000],
                  zorder=-500,
              )
  
      if title is not None and title != "":
          slicer.title(title)
      return slicer
  
file_path: nipy/nipy/labs/viz_tools/activation_maps.py
imports: import numbers
  import warnings
  import matplotlib.pyplot
  import numpy
  from nipy.utils import is_numlike
  from .anat_cache import _AnatCache, mni_sform, mni_sform_inv
  from .coord_tools import coord_transform, find_maxsep_cut_coords
  from .edge_detect import _fast_abs_percentile
  from .slicers import SLICERS, _xyz_order
label_desc: Use image node_id 2 for calling a global function with example usage: _plot_anat(slicer, anat, anat_affine, title, annotate, draw_cross, dim, cmap) and returns: slicer