class_docstr: This class connects a :class:`ColorbarBase` to a
  :class:`~matplotlib.cm.ScalarMappable` such as a
  :class:`~matplotlib.image.AxesImage` generated via
  :meth:`~matplotlib.axes.Axes.imshow`.
  
  It is not intended to be instantiated directly; instead,
  use :meth:`~matplotlib.figure.Figure.colorbar` or
  :func:`~matplotlib.pyplot.colorbar` to make your colorbar.
class_docstr_tok: ["This","class","connects","a",":","class",":","`","ColorbarBase","`","to","a",":","class",":","`","~matplotlib.cm.ScalarMappable","`","such","as","a",":","class",":","`","~matplotlib.image.AxesImage","`","generated","via",":","meth",":","`","~matplotlib.axes.Axes.imshow","`",".","It","is","not","intended","to","be","instantiated","directly",";","instead",",","use",":","meth",":","`","~matplotlib.figure.Figure.colorbar","`","or",":","func",":","`","~matplotlib.pyplot.colorbar","`","to","make","your","colorbar","."]
code: def __init__(self, ax, mappable, **kw):
      # Ensure the given mappable's norm has appropriate vmin and vmax set
      # even if mappable.draw has not yet been called.
      mappable.autoscale_None()
  
      self.mappable = mappable
      kw["cmap"] = cmap = mappable.cmap
      kw["norm"] = norm = mappable.norm
  
      if isinstance(mappable, contour.ContourSet):
          CS = mappable
          kw["alpha"] = mappable.get_alpha()
          kw["boundaries"] = CS._levels
          kw["values"] = CS.cvalues
          kw["extend"] = CS.extend
          # kw['ticks'] = CS._levels
          kw.setdefault(
              "ticks", ticker.FixedLocator(CS.levels, nbins=10)
          )
          kw["filled"] = CS.filled
          ColorbarBase.__init__(self, ax, **kw)
          if not CS.filled:
              self.add_lines(CS)
      else:
          if getattr(cmap, "colorbar_extend", False) is not False:
              kw.setdefault("extend", cmap.colorbar_extend)
  
          if isinstance(mappable, martist.Artist):
              kw["alpha"] = mappable.get_alpha()
  
          ColorbarBase.__init__(self, ax, **kw)
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  from six.moves import xrange, zip
  import warnings
  import numpy
  import matplotlib
  import matplotlib.artist
  import matplotlib.cbook
  import matplotlib.collections
  import matplotlib.colors
  import matplotlib.contour
  import matplotlib.cm
  import matplotlib.gridspec
  import matplotlib.patches
  import matplotlib.path
  import matplotlib.ticker
  import matplotlib.transforms
  import matplotlib._layoutbox
  import matplotlib._constrained_layout
  from matplotlib import docstring
label_desc: Use image node_id 1 to create a new Colorbar object from inherited base classes: ColorbarBase with example: obj = Colorbar(ax, mappable)