classmatplotlib.colorbar.Colorbar(ax, mappable=None, *, cmap=None, norm=None, alpha=None, values=None, boundaries=None, orientation='vertical', ticklocation='auto', extend=None, spacing='uniform', ticks=None, format=None, drawedges=False, filled=True, extendfrac=None, extendrect=False, label='')[source]
 
Bases: object Draw a colorbar in an existing axes. Typically, colorbars are created using Figure.colorbar or pyplot.colorbar and associated with ScalarMappables (such as an AxesImage generated via imshow). In order to draw a colorbar not associated with other elements in the figure, e.g. when showing a colormap by itself, one can create an empty ScalarMappable, or directly pass cmap and norm instead of mappable to Colorbar. Useful public methods are set_label() and add_lines().  Parameters 
 
axAxes


The Axes instance in which the colorbar is drawn.  
mappableScalarMappable


The mappable whose colormap and norm will be used. To show the under- and over- value colors, the mappable's norm should be specified as norm = colors.Normalize(clip=False)
 To show the colors versus index instead of on a 0-1 scale, use: norm=colors.NoNorm()
  
cmapColormap, default: rcParams["image.cmap"] (default: 'viridis')


The colormap to use. This parameter is ignored, unless mappable is None.  
normNormalize


The normalization to use. This parameter is ignored, unless mappable is None.  
alphafloat


The colorbar transparency between 0 (transparent) and 1 (opaque).  values, boundaries

If unset, the colormap will be displayed on a 0-1 scale.  
orientation{'vertical', 'horizontal'}


ticklocation{'auto', 'left', 'right', 'top', 'bottom'}


extend{'neither', 'both', 'min', 'max'}


spacing{'uniform', 'proportional'}


ticksLocator or array-like of float


formatstr or Formatter


drawedgesbool


filledbool

extendfrac
extendrec

labelstr

  Attributes 
 
axAxes


The Axes instance in which the colorbar is drawn.  
lineslist


A list of LineCollection (empty if no lines were drawn).  
dividersLineCollection


A LineCollection (empty if drawedges is False).       add_lines(*args, **kwargs)[source]
 
Draw lines on the colorbar. The lines are appended to the list lines.  Parameters 
 
levelsarray-like


The positions of the lines.  
colorscolor or list of colors


Either a single color applying to all lines or one color value for each line.  
linewidthsfloat or array-like


Either a single linewidth applying to all lines or one linewidth for each line.  
erasebool, default: True


Whether to remove any previously added lines.     Notes Alternatively, this method can also be called with the signature colorbar.add_lines(contour_set, erase=True), in which case levels, colors, and linewidths are taken from contour_set. 
   drag_pan(button, key, x, y)[source]

   draw_all()[source]
 
Calculate any free parameters based on the current cmap and norm, and do all the drawing. 
   get_ticks(minor=False)[source]
 
Return the ticks as a list of locations.  Parameters 
 
minorboolean, default: False


if True return the minor ticks.     
   minorticks_off()[source]
 
Turn the minor ticks of the colorbar off. 
   minorticks_on()[source]
 
Turn on colorbar minor ticks. 
   n_rasterize=50

   propertypatch[source]

   remove()[source]
 
Remove this colorbar from the figure. If the colorbar was created with use_gridspec=True the previous gridspec is restored. 
   set_alpha(alpha)[source]
 
Set the transparency between 0 (transparent) and 1 (opaque). If an array is provided, alpha will be set to None to use the transparency values associated with the colormap. 
   set_label(label, *, loc=None, **kwargs)[source]
 
Add a label to the long axis of the colorbar.  Parameters 
 
labelstr


The label text.  
locstr, optional


The location of the label.  For horizontal orientation one of {'left', 'center', 'right'} For vertical orientation one of {'bottom', 'center', 'top'}  Defaults to rcParams["xaxis.labellocation"] (default: 'center') or rcParams["yaxis.labellocation"] (default: 'center') depending on the orientation.  **kwargs

Keyword arguments are passed to set_xlabel / set_ylabel. Supported keywords are labelpad and Text properties.     
   set_ticklabels(ticklabels, update_ticks=<deprecated parameter>, *, minor=False, **kwargs)[source]
 
Set tick labels.  Discouraged The use of this method is discouraged, because of the dependency on tick positions. In most cases, you'll want to use set_ticks(positions, labels=labels) instead. If you are using this method, you should always fix the tick positions before, e.g. by using Colorbar.set_ticks or by explicitly setting a FixedLocator on the long axis of the colorbar. Otherwise, ticks are free to move and the labels may end up in unexpected positions.   Parameters 
 
ticklabelssequence of str or of Text


Texts for labeling each tick location in the sequence set by Colorbar.set_ticks; the number of labels must match the number of locations.  
update_ticksbool, default: True

 This keyword argument is ignored and will be be removed. Deprecated  minorbool


If True, set minor ticks instead of major ticks.    **kwargs

Text properties for the labels.     
   set_ticks(ticks, update_ticks=<deprecated parameter>, labels=None, *, minor=False, **kwargs)[source]
 
Set tick locations.  Parameters 
 
tickslist of floats


List of tick locations.  
labelslist of str, optional


List of tick labels. If not set, the labels show the data value.  
minorbool, default: False


If False, set the major ticks; if True, the minor ticks.  **kwargs

Text properties for the labels. These take effect only if you pass labels. In other cases, please use tick_params.     
   update_normal(mappable)[source]
 
Update solid patches, lines, etc. This is meant to be called when the norm of the image or contour plot to which this colorbar belongs changes. If the norm on the mappable is different than before, this resets the locator and formatter for the axis, so if these have been customized, they will need to be customized again. However, if the norm only changes values of vmin, vmax or cmap then the old formatter and locator will be preserved. 
   update_ticks()[source]
 
Setup the ticks and ticklabels. This should not be needed by users.