code: def plot_rgb(
      arr,
      rgb=(0, 1, 2),
      figsize=(10, 10),
      str_clip=2,
      ax=None,
      extent=None,
      title="",
      stretch=None,
  ):
      """Plot three bands in a numpy array as a composite RGB image.
  
      Parameters
      ----------
      arr : numpy array
          An n-dimensional array in rasterio band order (bands, rows, columns)
          containing the layers to plot.
      rgb : list (default = (0, 1, 2))
          Indices of the three bands to be plotted.
      figsize : tuple (default = (10, 10)
          The x and y integer dimensions of the output plot.
      str_clip: int (default = 2)
          The percentage of clip to apply to the stretch. Default = 2 (2 and 98).
      ax : object (optional)
          The axes object where the ax element should be plotted.
      extent : tuple (optional)
          The extent object that matplotlib expects (left, right, bottom, top).
      title : string (optional)
          The intended title of the plot.
      stretch : Boolean (optional)
          Application of a linear stretch. If set to True, a linear stretch will
          be applied.
  
      Returns
      ----------
      ax : axes object
          The axes object associated with the 3 band image.
  
      Example
      -------
  
      .. plot::
  
          >>> import matplotlib.pyplot as plt
          >>> import rasterio as rio
          >>> import earthpy.plot as ep
          >>> from earthpy.io import path_to_example
          >>> with rio.open(path_to_example('rmnp-rgb.tif')) as src:
          ...     img_array = src.read()
          >>> # Ensure the input array doesn't have nodata values like -9999
          >>> ep.plot_rgb(img_array)
          <Axes: >
  
      """
  
      if len(arr.shape) != 3:
          raise ValueError(
              "Input needs to be 3 dimensions and in rasterio "
              "order with bands first"
          )
  
      # Index bands for plotting and clean up data for matplotlib
      rgb_bands = arr[rgb, :, :]
  
      if stretch:
          rgb_bands = _stretch_im(rgb_bands, str_clip)
  
      nan_check = np.isnan(rgb_bands)
  
      if np.any(nan_check):
          rgb_bands = np.ma.masked_array(rgb_bands, nan_check)
  
      # If type is masked array - add alpha channel for plotting
      if ma.is_masked(rgb_bands):
          # Build alpha channel
          mask = ~(np.ma.getmask(rgb_bands[0])) * 255
  
          # Add the mask to the array & swap the axes order from (bands,
          # rows, columns) to (rows, columns, bands) for plotting
          rgb_bands = np.vstack(
              (es.bytescale(rgb_bands), np.expand_dims(mask, axis=0))
          ).transpose([1, 2, 0])
      else:
          # Index bands for plotting and clean up data for matplotlib
          rgb_bands = es.bytescale(rgb_bands).transpose([1, 2, 0])
  
      # Then plot. Define ax if it's undefined
      show = False
      if ax is None:
          fig, ax = plt.subplots(figsize=figsize)
          show = True
  
      ax.imshow(rgb_bands, extent=extent)
      ax.set_title(title)
      ax.set(xticks=[], yticks=[])
  
      # Multipanel won't work if plt.show is called prior to second plot def
      if show:
          plt.show()
      return ax
  
file_path: earthpy/earthpy/plot.py
imports: import numpy
  import numpy.ma
  import matplotlib.pyplot
  from matplotlib import patches
  from matplotlib.colors import ListedColormap
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  from skimage import exposure
  import earthpy.spatial
label_desc: Use image node_id 5 for calling a global function with example usage: plot_rgb(arr, rgb, figsize, str_clip, ax, extent, title, stretch) and returns: ax