class_docstr: An MPL axis-like object that displays a cut of 3D volumes.
  
  Parameters
  ----------
  %(ax)s
  direction : {'x', 'y', 'z'}
      The directions of the view.
  
  coord : :obj:`float`
      The coordinate along the direction of the cut.
class_docstr_tok: ["An","MPL","axis-like","object","that","displays","a","cut","of","3D","volumes",".","Parameters","--","--","--","--","--","%","(","ax",")","s","direction",":","{","'","x","'",",","'","y","'",",","'","z","'","}","The","directions","of","the","view",".","coord",":",":","obj",":","`","float","`","The","coordinate","along","the","direction","of","the","cut","."]
docstr: Cut the 3D volume into a 2D slice.
  
  Parameters
  ----------
  data : 3D :class:`~numpy.ndarray`
      The 3D volume to cut.
  
  affine : 4x4 :class:`~numpy.ndarray`
      The affine of the volume.
docstr_tok: ["Cut","the","3D","volume","into","a","2D","slice",".","Parameters","--","--","--","--","--","data",":","3D",":","class",":","`","~numpy.ndarray","`","The","3D","volume","to","cut",".","affine",":","4x4",":","class",":","`","~numpy.ndarray","`","The","affine","of","the","volume","."]
code: def transform_to_2d(self, data, affine):
      """Cut the 3D volume into a 2D slice.
  
      Parameters
      ----------
      data : 3D :class:`~numpy.ndarray`
          The 3D volume to cut.
  
      affine : 4x4 :class:`~numpy.ndarray`
          The affine of the volume.
  
      """
      coords = [0, 0, 0]
      if self.direction not in ["x", "y", "z"]:
          raise ValueError(
              f"Invalid value for direction {self.direction}"
          )
      coords["xyz".index(self.direction)] = self.coord
      x_map, y_map, z_map = (
          int(np.round(c))
          for c in coord_transform(
              coords[0], coords[1], coords[2], np.linalg.inv(affine)
          )
      )
      if self.direction == "y":
          cut = np.rot90(data[:, y_map, :])
      elif self.direction == "x":
          cut = np.rot90(data[x_map, :, :])
      elif self.direction == "z":
          cut = np.rot90(data[:, :, z_map])
      return cut
  
imports: import numbers
  import matplotlib.pyplot
  import numpy
  from matplotlib.colors import Normalize
  from matplotlib.font_manager import FontProperties
  from matplotlib.lines import Line2D
  from matplotlib.patches import FancyArrow
  from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
  from nilearn._utils.docs import fill_doc
  from nilearn.image import coord_transform
  from nilearn.plotting.glass_brain import plot_brain_schematics
label_desc: Use image node_id 1 for calling the CutAxes obj's underlying member method code with example usage: obj.transform_to_2d(data, affine) and returns: cut