<divid="unreleased-message"> You are reading an old version of the documentation (v3.3.2). For the latest version see <ahref="https://matplotlib.org/stable/api/colorbar_api.html">https://matplotlib.org/stable/api/colorbar_api.html</a></div>
<spanid="matplotlib-colorbar"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.colorbar</span></code><aclass="headerlink" href="#module-matplotlib.colorbar" title="Permalink to this headline">¶</a></h1>
<p>Colorbars are a visualization of the mapping from scalar values to colors.
In Matplotlib they are drawn into a dedicated <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a>.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<p>Colorbars are typically created through <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure.colorbar</span></code></a> or its pyplot
<pclass="last">As an end-user, you most likely won't have to call the methods or
instantiate the classes in this module explicitly.</p>
</div>
<dlclass="docutils">
<dt><aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase" title="matplotlib.colorbar.ColorbarBase"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">ColorbarBase</span></code></a></dt><dd>The base class with full colorbar drawing functionality.
It can be used as-is to make a colorbar for a given colormap;
a mappable object (e.g., image) is not needed.</dd>
<dt><aclass="reference internal" href="#matplotlib.colorbar.Colorbar" title="matplotlib.colorbar.Colorbar"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Colorbar</span></code></a></dt><dd>On top of <aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase" title="matplotlib.colorbar.ColorbarBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ColorbarBase</span></code></a> this connects the colorbar with a
<aclass="reference internal" href="cm_api.html#matplotlib.cm.ScalarMappable" title="matplotlib.cm.ScalarMappable"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ScalarMappable</span></code></a> such as an image or contour plot.</dd>
<dt><aclass="reference internal" href="#matplotlib.colorbar.make_axes" title="matplotlib.colorbar.make_axes"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">make_axes()</span></code></a></dt><dd>Create an <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> suitable for a colorbar. This functions can be
used with figures containing a single axes or with freely placed axes.</dd>
<dt><aclass="reference internal" href="#matplotlib.colorbar.make_axes_gridspec" title="matplotlib.colorbar.make_axes_gridspec"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">make_axes_gridspec()</span></code></a></dt><dd>Create a <aclass="reference internal" href="_as_gen/matplotlib.axes.SubplotBase.html#matplotlib.axes.SubplotBase" title="matplotlib.axes.SubplotBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">SubplotBase</span></code></a> suitable for a colorbar. This function should
be used for adding a colorbar to a <aclass="reference internal" href="_as_gen/matplotlib.gridspec.GridSpec.html#matplotlib.gridspec.GridSpec" title="matplotlib.gridspec.GridSpec"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">GridSpec</span></code></a>.</dd>
</dl>
<dlclass="py class">
<dtid="matplotlib.colorbar.Colorbar">
<emclass="property">class </em><codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">Colorbar</code><spanclass="sig-paren">(</span><em><spanclass="n">ax</span></em>, <em><spanclass="n">mappable</span></em>, <em><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#Colorbar"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.Colorbar" title="Permalink to this definition">¶</a></dt>
<p>This class connects a <aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase" title="matplotlib.colorbar.ColorbarBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ColorbarBase</span></code></a> to a <aclass="reference internal" href="cm_api.html#matplotlib.cm.ScalarMappable" title="matplotlib.cm.ScalarMappable"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ScalarMappable</span></code></a>
such as an <aclass="reference internal" href="image_api.html#matplotlib.image.AxesImage" title="matplotlib.image.AxesImage"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">AxesImage</span></code></a> generated via <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.imshow.html#matplotlib.axes.Axes.imshow" title="matplotlib.axes.Axes.imshow"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">imshow</span></code></a>.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">This class is not intended to be instantiated directly; instead, use
<aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure.colorbar</span></code></a> or <aclass="reference internal" href="_as_gen/matplotlib.pyplot.colorbar.html#matplotlib.pyplot.colorbar" title="matplotlib.pyplot.colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">pyplot.colorbar</span></code></a> to create a colorbar.</p>
</div>
<dlclass="py method">
<dtid="matplotlib.colorbar.Colorbar.add_lines">
<codeclass="descname">add_lines</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">CS</span></em>, <em><spanclass="n">erase</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#Colorbar.add_lines"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.add_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Add the lines from a non-filled <aclass="reference internal" href="contour_api.html#matplotlib.contour.ContourSet" title="matplotlib.contour.ContourSet"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ContourSet</span></code></a> to the colorbar.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>CS</strong><spanclass="classifier"><aclass="reference internal" href="contour_api.html#matplotlib.contour.ContourSet" title="matplotlib.contour.ContourSet"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ContourSet</span></code></a></span></dt><dd><p>The line positions are taken from the ContourSet levels. The
ContourSet must not be filled.</p>
</dd>
<dt><strong>erase</strong><spanclass="classifier">bool, default: True</span></dt><dd><p>Whether to remove any previously added lines.</p>
<codeclass="descname">on_mappable_changed</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">mappable</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#Colorbar.on_mappable_changed"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.on_mappable_changed" title="Permalink to this definition">¶</a></dt>
<dd><p>[<em>Deprecated</em>] Update this colorbar to match the mappable's properties.</p>
<p>Typically this is automatically registered as an event handler
by <aclass="reference internal" href="#matplotlib.colorbar.colorbar_factory" title="matplotlib.colorbar.colorbar_factory"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">colorbar_factory()</span></code></a> and should not be called manually.</p>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified deprecated">Deprecated since version 3.3.</span></p>
</div>
</dd></dl>
<dlclass="py method">
<dtid="matplotlib.colorbar.Colorbar.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#Colorbar.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove this colorbar from the figure.</p>
<p>If the colorbar was created with <codeclass="docutils literal notranslate"><spanclass="pre">use_gridspec=True</span></code> the previous
<codeclass="descname">update_bruteforce</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">mappable</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#Colorbar.update_bruteforce"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.update_bruteforce" title="Permalink to this definition">¶</a></dt>
<dd><p>[<em>Deprecated</em>] Destroy and rebuild the colorbar. This is
intended to become obsolete, and will probably be
deprecated and then removed. It is not called when
the pyplot.colorbar function or the Figure.colorbar
method are used to create the colorbar.</p>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified deprecated">Deprecated since version 3.3.</span></p>
<codeclass="descname">update_normal</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">mappable</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#Colorbar.update_normal"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.update_normal" title="Permalink to this definition">¶</a></dt>
<dd><p>Update solid patches, lines, etc.</p>
<p>This is meant to be called when the norm of the image or contour plot
to which this colorbar belongs changes.</p>
<p>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 <em>vmin</em>, <em>vmax</em> or <em>cmap</em> then the old formatter
<p>There are only some rare cases in which you would work directly with a
<aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase" title="matplotlib.colorbar.ColorbarBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ColorbarBase</span></code></a> as an end-user. Typically, colorbars are used
with <aclass="reference internal" href="cm_api.html#matplotlib.cm.ScalarMappable" title="matplotlib.cm.ScalarMappable"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ScalarMappable</span></code></a>s such as an <aclass="reference internal" href="image_api.html#matplotlib.image.AxesImage" title="matplotlib.image.AxesImage"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">AxesImage</span></code></a> generated via
<aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.imshow.html#matplotlib.axes.Axes.imshow" title="matplotlib.axes.Axes.imshow"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">imshow</span></code></a>. For these cases you will use <aclass="reference internal" href="#matplotlib.colorbar.Colorbar" title="matplotlib.colorbar.Colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Colorbar</span></code></a> and
likely create it via <aclass="reference internal" href="_as_gen/matplotlib.pyplot.colorbar.html#matplotlib.pyplot.colorbar" title="matplotlib.pyplot.colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">pyplot.colorbar</span></code></a> or <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure.colorbar</span></code></a>.</p>
<p>The main application of using a <aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase" title="matplotlib.colorbar.ColorbarBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ColorbarBase</span></code></a> explicitly is drawing
colorbars that are not associated with other elements in the figure, e.g.
when showing a colormap by itself.</p>
<p>If the <em>cmap</em> kwarg is given but <em>boundaries</em> and <em>values</em> are left as
None, then the colormap will be displayed on a 0-1 scale. To show the
under- and over-value colors, specify the <em>norm</em> as:</p>
<trclass="field-even field"><thclass="field-name">Attributes:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>ax</strong><spanclass="classifier"><aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a></span></dt><dd><p>The <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> instance in which the colorbar is drawn.</p>
</dd>
<dt><strong>lines</strong><spanclass="classifier">list</span></dt><dd><p>A list of <aclass="reference internal" href="collections_api.html#matplotlib.collections.LineCollection" title="matplotlib.collections.LineCollection"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">LineCollection</span></code></a> if lines were drawn, otherwise
an empty list.</p>
</dd>
<dt><strong>dividers</strong><spanclass="classifier"><aclass="reference internal" href="collections_api.html#matplotlib.collections.LineCollection" title="matplotlib.collections.LineCollection"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">LineCollection</span></code></a></span></dt><dd><p>A LineCollection if <em>drawedges</em> is <codeclass="docutils literal notranslate"><spanclass="pre">True</span></code>, otherwise <codeclass="docutils literal notranslate"><spanclass="pre">None</span></code>.</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>levels</strong><spanclass="classifier">array-like</span></dt><dd><p>The positions of the lines.</p>
</dd>
<dt><strong>colors</strong><spanclass="classifier">color or list of colors</span></dt><dd><p>Either a single color applying to all lines or one color value for
each line.</p>
</dd>
<dt><strong>linewidths</strong><spanclass="classifier">float or array-like</span></dt><dd><p>Either a single linewidth applying to all lines or one linewidth
for each line.</p>
</dd>
<dt><strong>erase</strong><spanclass="classifier">bool, default: True</span></dt><dd><p>Whether to remove any previously added lines.</p>
<codeclass="descname">config_axis</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.config_axis"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.config_axis" title="Permalink to this definition">¶</a></dt>
<dd><p>[<em>Deprecated</em>]</p>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified deprecated">Deprecated since version 3.3: </span></p>
<codeclass="descname">draw_all</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.draw_all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.draw_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculate any free parameters based on the current cmap and norm,
<codeclass="descname">get_ticks</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">minor</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.get_ticks"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.get_ticks" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the x ticks as a list of locations.</p>
<codeclass="descname">minorticks_off</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.minorticks_off"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.minorticks_off" title="Permalink to this definition">¶</a></dt>
<dd><p>Turn the minor ticks of the colorbar off.</p>
<codeclass="descname">minorticks_on</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.minorticks_on"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.minorticks_on" title="Permalink to this definition">¶</a></dt>
<dd><p>Turn the minor ticks of the colorbar on without extruding
<codeclass="descname">n_rasterize</code><emclass="property"> = 50</em><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.n_rasterize" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="py method">
<dtid="matplotlib.colorbar.ColorbarBase.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.remove" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">set_alpha</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">alpha</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.set_alpha"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_alpha" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the transparency between 0 (transparent) and 1 (opaque).</p>
<codeclass="descname">set_ticklabels</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">ticklabels</span></em>, <em><spanclass="n">update_ticks</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.set_ticklabels"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_ticklabels" title="Permalink to this definition">¶</a></dt>
<dd><p>Set tick labels.</p>
<p>Tick labels are updated immediately unless <em>update_ticks</em> is <em>False</em>,
in which case one should call <aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase.update_ticks" title="matplotlib.colorbar.ColorbarBase.update_ticks"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">update_ticks</span></code></a> explicitly.</p>
<codeclass="descname">set_ticks</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em>, <em><spanclass="n">ticks</span></em>, <em><spanclass="n">update_ticks</span><spanclass="o">=</span><spanclass="default_value">True</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.set_ticks"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_ticks" title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>ticks</strong><spanclass="classifier">array-like or <aclass="reference internal" href="ticker_api.html#matplotlib.ticker.Locator" title="matplotlib.ticker.Locator"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Locator</span></code></a> or None</span></dt><dd><p>The tick positions can be hard-coded by an array of values; or
they can be defined by a <aclass="reference internal" href="ticker_api.html#matplotlib.ticker.Locator" title="matplotlib.ticker.Locator"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Locator</span></code></a>. Setting to <em>None</em> reverts
to using a default locator.</p>
</dd>
<dt><strong>update_ticks</strong><spanclass="classifier">bool, default: True</span></dt><dd><p>If True, tick locations are updated immediately. If False, the
user has to call <aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase.update_ticks" title="matplotlib.colorbar.ColorbarBase.update_ticks"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">update_ticks</span></code></a> later to update the ticks.</p>
<codeclass="descname">update_ticks</code><spanclass="sig-paren">(</span><em><spanclass="n">self</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.update_ticks"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.update_ticks" title="Permalink to this definition">¶</a></dt>
<dd><p>Force the update of the ticks and ticklabels. This must be
called whenever the tick locator and/or tick formatter changes.</p>
</dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="matplotlib.colorbar.ColorbarPatch">
<emclass="property">class </em><codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">ColorbarPatch</code><spanclass="sig-paren">(</span><em><spanclass="n">ax</span></em>, <em><spanclass="n">mappable</span></em>, <em><spanclass="o">**</span><spanclass="n">kw</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarPatch"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.ColorbarPatch" title="Permalink to this definition">¶</a></dt>
<p>A Colorbar that uses a list of <aclass="reference internal" href="_as_gen/matplotlib.patches.Patch.html#matplotlib.patches.Patch" title="matplotlib.patches.Patch"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Patch</span></code></a> instances rather than the
because the latter does not allow the hatch pattern to vary among the
members of the collection.</p>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.colorbar.colorbar_factory">
<codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">colorbar_factory</code><spanclass="sig-paren">(</span><em><spanclass="n">cax</span></em>, <em><spanclass="n">mappable</span></em>, <em><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#colorbar_factory"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.colorbar_factory" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a colorbar on the given axes for the given mappable.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">This is a low-level function to turn an existing axes into a colorbar
axes. Typically, you'll want to use <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">colorbar</span></code></a> instead, which
automatically handles creation and placement of a suitable axes as
<dt><strong>cax</strong><spanclass="classifier"><aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a></span></dt><dd><p>The <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> to turn into a colorbar.</p>
</dd>
<dt><strong>mappable</strong><spanclass="classifier"><aclass="reference internal" href="cm_api.html#matplotlib.cm.ScalarMappable" title="matplotlib.cm.ScalarMappable"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ScalarMappable</span></code></a></span></dt><dd><p>The mappable to be described by the colorbar.</p>
</dd>
<dt><strong>**kwargs</strong></dt><dd><p>Keyword arguments are passed to the respective colorbar class.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><aclass="reference internal" href="#matplotlib.colorbar.Colorbar" title="matplotlib.colorbar.Colorbar"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Colorbar</span></code></a> or <aclass="reference internal" href="#matplotlib.colorbar.ColorbarPatch" title="matplotlib.colorbar.ColorbarPatch"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ColorbarPatch</span></code></a></dt><dd><p>The created colorbar instance. <aclass="reference internal" href="#matplotlib.colorbar.ColorbarPatch" title="matplotlib.colorbar.ColorbarPatch"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ColorbarPatch</span></code></a> is only used if
<em>mappable</em> is a <aclass="reference internal" href="contour_api.html#matplotlib.contour.ContourSet" title="matplotlib.contour.ContourSet"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">ContourSet</span></code></a> with hatches.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.colorbar.make_axes">
<codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">make_axes</code><spanclass="sig-paren">(</span><em><spanclass="n">parents</span></em>, <em><spanclass="n">location</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <em><spanclass="n">orientation</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <em><spanclass="n">fraction</span><spanclass="o">=</span><spanclass="default_value">0.15</span></em>, <em><spanclass="n">shrink</span><spanclass="o">=</span><spanclass="default_value">1.0</span></em>, <em><spanclass="n">aspect</span><spanclass="o">=</span><spanclass="default_value">20</span></em>, <em><spanclass="o">**</span><spanclass="n">kw</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#make_axes"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.make_axes" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> suitable for a colorbar.</p>
<p>The axes is placed in the figure of the <em>parents</em> axes, by resizing and
<dt><strong>parents</strong><spanclass="classifier"><aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a> or list of <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a></span></dt><dd><p>The Axes to use as parents for placing the colorbar.</p>
</dd>
<dt><strong>location</strong><spanclass="classifier">None or {'left', 'right', 'top', 'bottom'}</span></dt><dd><p>The position, relative to <em>parents</em>, where the colorbar axes
should be created. If None, the value will either come from the
given <codeclass="docutils literal notranslate"><spanclass="pre">orientation</span></code>, else it will default to 'right'.</p>
</dd>
<dt><strong>orientation</strong><spanclass="classifier">None or {'vertical', 'horizontal'}</span></dt><dd><p>The orientation of the colorbar. Typically, this keyword shouldn't
be used, as it can be derived from the <codeclass="docutils literal notranslate"><spanclass="pre">location</span></code> keyword.</p>
</dd>
<dt><strong>fraction</strong><spanclass="classifier">float, default: 0.15</span></dt><dd><p>Fraction of original axes to use for colorbar.</p>
</dd>
<dt><strong>shrink</strong><spanclass="classifier">float, default: 1.0</span></dt><dd><p>Fraction by which to multiply the size of the colorbar.</p>
</dd>
<dt><strong>aspect</strong><spanclass="classifier">float, default: 20</span></dt><dd><p>Ratio of long to short dimensions.</p>
<dt><strong>kw</strong><spanclass="classifier">dict</span></dt><dd><p>The reduced keyword dictionary to be passed when creating the colorbar
instance.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-odd field"><thclass="field-name">Other Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>pad</strong><spanclass="classifier">float, default: 0.05 if vertical, 0.15 if horizontal</span></dt><dd><p>Fraction of original axes between colorbar and new image axes.</p>
</dd>
<dt><strong>anchor</strong><spanclass="classifier">(float, float), optional</span></dt><dd><p>The anchor point of the colorbar axes.
Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.</p>
</dd>
<dt><strong>panchor</strong><spanclass="classifier">(float, float), or <em>False</em>, optional</span></dt><dd><p>The anchor point of the colorbar parent axes. If <em>False</em>, the parent
axes' anchor will be unchanged.
Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dlclass="py function">
<dtid="matplotlib.colorbar.make_axes_gridspec">
<codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">make_axes_gridspec</code><spanclass="sig-paren">(</span><em><spanclass="n">parent</span></em>, <em><spanclass="o">*</span></em>, <em><spanclass="n">fraction</span><spanclass="o">=</span><spanclass="default_value">0.15</span></em>, <em><spanclass="n">shrink</span><spanclass="o">=</span><spanclass="default_value">1.0</span></em>, <em><spanclass="n">aspect</span><spanclass="o">=</span><spanclass="default_value">20</span></em>, <em><spanclass="o">**</span><spanclass="n">kw</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#make_axes_gridspec"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.colorbar.make_axes_gridspec" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <aclass="reference internal" href="_as_gen/matplotlib.axes.SubplotBase.html#matplotlib.axes.SubplotBase" title="matplotlib.axes.SubplotBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">SubplotBase</span></code></a> suitable for a colorbar.</p>
<p>The axes is placed in the figure of the <em>parent</em> axes, by resizing and
repositioning <em>parent</em>.</p>
<p>This function is similar to <aclass="reference internal" href="#matplotlib.colorbar.make_axes" title="matplotlib.colorbar.make_axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">make_axes</span></code></a>. Primary differences are</p>
<ulclass="simple">
<li><aclass="reference internal" href="#matplotlib.colorbar.make_axes_gridspec" title="matplotlib.colorbar.make_axes_gridspec"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">make_axes_gridspec</span></code></a> only handles the <em>orientation</em> keyword
and cannot handle the <em>location</em> keyword.</li>
<li><aclass="reference internal" href="#matplotlib.colorbar.make_axes_gridspec" title="matplotlib.colorbar.make_axes_gridspec"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">make_axes_gridspec</span></code></a> should only be used with a <aclass="reference internal" href="_as_gen/matplotlib.axes.SubplotBase.html#matplotlib.axes.SubplotBase" title="matplotlib.axes.SubplotBase"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">SubplotBase</span></code></a> parent.</li>
<li><aclass="reference internal" href="#matplotlib.colorbar.make_axes" title="matplotlib.colorbar.make_axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">make_axes</span></code></a> updates the position of the parent. <aclass="reference internal" href="#matplotlib.colorbar.make_axes_gridspec" title="matplotlib.colorbar.make_axes_gridspec"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">make_axes_gridspec</span></code></a>
replaces the <codeclass="docutils literal notranslate"><spanclass="pre">grid_spec</span></code> attribute of the parent with a new one.</li>
</ul>
<p>While this function is meant to be compatible with <aclass="reference internal" href="#matplotlib.colorbar.make_axes" title="matplotlib.colorbar.make_axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">make_axes</span></code></a>,
<dt><strong>parent</strong><spanclass="classifier"><aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes</span></code></a></span></dt><dd><p>The Axes to use as parent for placing the colorbar.</p>
</dd>
<dt><strong>fraction</strong><spanclass="classifier">float, default: 0.15</span></dt><dd><p>Fraction of original axes to use for colorbar.</p>
</dd>
<dt><strong>shrink</strong><spanclass="classifier">float, default: 1.0</span></dt><dd><p>Fraction by which to multiply the size of the colorbar.</p>
</dd>
<dt><strong>aspect</strong><spanclass="classifier">float, default: 20</span></dt><dd><p>Ratio of long to short dimensions.</p>
<dt><strong>kw</strong><spanclass="classifier">dict</span></dt><dd><p>The reduced keyword dictionary to be passed when creating the colorbar
instance.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-odd field"><thclass="field-name">Other Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>orientation</strong><spanclass="classifier">{'vertical', 'horizontal'}, default: 'vertical'</span></dt><dd><p>The orientation of the colorbar.</p>
</dd>
<dt><strong>pad</strong><spanclass="classifier">float, default: 0.05 if vertical, 0.15 if horizontal</span></dt><dd><p>Fraction of original axes between colorbar and new image axes.</p>
</dd>
<dt><strong>anchor</strong><spanclass="classifier">(float, float), optional</span></dt><dd><p>The anchor point of the colorbar axes.
Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.</p>
</dd>
<dt><strong>panchor</strong><spanclass="classifier">(float, float), or <em>False</em>, optional</span></dt><dd><p>The anchor point of the colorbar parent axes. If <em>False</em>, the parent
axes' anchor will be unchanged.
Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.</p>