code: def _plot_colorbar(mappable, fig, subplot_spec, max_cbar_height=4):
      
      width, height = fig.get_size_inches()
      if height > max_cbar_height:
          # to make the colorbar shorter, the
          # ax is split and the lower portion is used.
          axs2 = gridspec.GridSpecFromSubplotSpec(2, 1, subplot_spec=subplot_spec,
                                                  height_ratios=[height - max_cbar_height, max_cbar_height])
          heatmap_cbar_ax = fig.add_subplot(axs2[1])
      else:
          heatmap_cbar_ax = fig.add_subplot(subplot_spec)
      pl.colorbar(mappable, cax=heatmap_cbar_ax)
      return heatmap_cbar_ax
docs: Plots a vertical color bar based on mappable.
      The height of the colorbar is min(figure-height, max_cmap_height)
  
      Parameters
      ----------
      mappable : The image to which the colorbar applies.
      fig ; The figure object
      subplot_spec : the gridspec subplot. Eg. axs[1,2]
      max_cbar_height : `float`
          The maximum colorbar height
  
      Returns
      -------
      color bar ax