code: def colorbar(mapobj, size="3%", pad=0.09):
      """Adjust colorbar height to match the matplotlib axis height.
  
      NOTE: This function requires matplotlib v 3.0.1 or greater or v 2.9 or
      lower to run properly.
  
      Parameters
      ----------
      mapobj : matplotlib axis object
          The image that the colorbar will be representing as a matplotlib axis
          object.
      size : char (default = "3%")
          The percent width of the colorbar relative to the plot.
      pad : int (default = 0.09)
          The space between the plot and the color bar.
  
      Returns
      -------
      matplotlib.pyplot.colorbar
  
          Matplotlib color bar object with the correct width that matches the
          y-axis height.
  
      Examples
      --------
  
      .. 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-dem.tif')) as src:
          ...     dem = src.read()
          ...     fig, ax = plt.subplots(figsize = (10, 5))
          >>> im = ax.imshow(dem.squeeze())
          >>> ep.colorbar(im)
          <matplotlib.colorbar.Colorbar object at 0x...>
          >>> ax.set(title="Rocky Mountain National Park DEM")
          [Text(...'Rocky Mountain National Park DEM')]
          >>> ax.set_axis_off()
          >>> plt.show()
      """
  
      try:
          ax = mapobj.axes
      except AttributeError:
          raise AttributeError(
              "The colorbar function requires a matplotlib axis object. "
              "You have provided a {}.".format(type(mapobj))
          )
      fig = ax.figure
      divider = make_axes_locatable(ax)
      cax = divider.append_axes("right", size=size, pad=pad)
      return fig.colorbar(mapobj, cax=cax)
  
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 1 for calling a global function with example usage: colorbar(mapobj, size, pad) and returns: fig