code: def show(
      source,
      with_bounds=True,
      contour=False,
      contour_label_kws=None,
      ax=None,
      title=None,
      transform=None,
      adjust=False,
      **kwargs,
  ):
      """Display a raster or raster band using matplotlib.
  
      Parameters
      ----------
      source : array or dataset object opened in 'r' mode or Band or tuple(dataset, bidx)
          If Band or tuple (dataset, bidx), display the selected band.
          If raster dataset display the rgb image
          as defined in the colorinterp metadata, or default to first band.
      with_bounds : bool (opt)
          Whether to change the image extent to the spatial bounds of the image,
          rather than pixel coordinates. Only works when source is
          (raster dataset, bidx) or raster dataset.
      contour : bool (opt)
          Whether to plot the raster data as contours
      contour_label_kws : dictionary (opt)
          Keyword arguments for labeling the contours,
          empty dictionary for no labels.
      ax : matplotlib.axes.Axes, optional
          Axes to plot on, otherwise uses current axes.
      title : str, optional
          Title for the figure.
      transform : Affine, optional
          Defines the affine transform if source is an array
      adjust : bool
          If the plotted data is an RGB image, adjust the values of
          each band so that they fall between 0 and 1 before plotting. If
          True, values will be adjusted by the min / max of each band. If
          False, no adjustment will be applied.
      **kwargs : key, value pairings optional
          These will be passed to the :func:`matplotlib.pyplot.imshow` or
          :func:`matplotlib.pyplot.contour` contour method depending on contour argument.
  
      Returns
      -------
      ax : matplotlib.axes.Axes
          Axes with plot.
  
      """
      plt = get_plt()
  
      if isinstance(source, tuple):
          arr = source[0].read(source[1])
  
          if len(arr.shape) >= 3:
              arr = reshape_as_image(arr)
  
          if with_bounds:
              kwargs["extent"] = plotting_extent(source[0])
  
      elif isinstance(source, DatasetReader):
          if with_bounds:
              kwargs["extent"] = plotting_extent(source)
  
          if source.count == 1:
              arr = source.read(1, masked=True)
          else:
              try:
                  # Lookup table for the color space in the source file.
                  # This will allow us to re-order it to RGB if needed
                  source_colorinterp = OrderedDict(
                      zip(source.colorinterp, source.indexes)
                  )
                  colorinterp = rasterio.enums.ColorInterp
  
                  # Gather the indexes of the RGB channels in that order
                  rgb_indexes = [
                      source_colorinterp[ci]
                      for ci in (
                          colorinterp.red,
                          colorinterp.green,
                          colorinterp.blue,
                      )
                  ]
  
                  # Read the image in the proper order so the numpy array
                  # will have the colors in the order expected by
                  # matplotlib (RGB)
                  arr = source.read(rgb_indexes, masked=True)
                  arr = reshape_as_image(arr)
  
              except KeyError:
                  arr = source.read(1, masked=True)
      else:
          # The source is a numpy array reshape it to image if it has 3+ bands
          if source.ndim >= 3:
              source = np.ma.squeeze(source)
  
          if source.ndim >= 3:
              arr = reshape_as_image(source)
          else:
              arr = source
  
          if transform and with_bounds:
              kwargs["extent"] = plotting_extent(arr, transform)
  
      if adjust and arr.ndim >= 3:
          # Adjust each band by the min/max so it will plot as RGB.
          arr = reshape_as_raster(arr).astype("float64")
  
          for ii, band in enumerate(arr):
              arr[ii] = adjust_band(band)
  
          arr = reshape_as_image(arr)
  
      show = False
  
      if not ax:
          show = True
          ax = plt.gca()
  
      if contour:
          if "cmap" not in kwargs:
              kwargs["colors"] = kwargs.get("colors", "red")
  
          kwargs["linewidths"] = kwargs.get("linewidths", 1.5)
          kwargs["alpha"] = kwargs.get("alpha", 0.8)
  
          C = ax.contour(arr, origin="upper", **kwargs)
  
          if contour_label_kws is None:
              # no explicit label kws passed use defaults
              contour_label_kws = dict(fontsize=8, inline=True)
  
          if contour_label_kws:
              ax.clabel(C, **contour_label_kws)
      else:
          ax.imshow(arr, **kwargs)
  
      if title:
          ax.set_title(title, fontweight="bold")
  
      if show:
          plt.show()
  
      return ax
  
file_path: rasterio/rasterio/plot.py
imports: import builtins
  from collections import OrderedDict
  import logging
  import numpy
  import rasterio
  from rasterio.io import DatasetReader
  from rasterio.transform import guard_transform
label_desc: Use image node_id 2 for calling a global function with example usage: show(source, with_bounds, contour, contour_label_kws, ax, title, transform, adjust) and returns: ax