<divid="unreleased-message"> You are reading an old version of the documentation (v1.5.3). For the latest version see <ahref="https://matplotlib.org/stable/api/colorbar_api.html">https://matplotlib.org/stable/api/colorbar_api.html</a></div>
and <aclass="reference internal" href="#matplotlib.colorbar.Colorbar" title="matplotlib.colorbar.Colorbar"><codeclass="xref py py-class docutils literal"><spanclass="pre">Colorbar</span></code></a>; the <aclass="reference internal" href="pyplot_api.html#matplotlib.pyplot.colorbar" title="matplotlib.pyplot.colorbar"><codeclass="xref py py-func docutils literal"><spanclass="pre">colorbar()</span></code></a> function
is a thin wrapper over <aclass="reference internal" href="figure_api.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-meth docutils literal"><spanclass="pre">colorbar()</span></code></a>.</p>
<dlclass="class">
<dtid="matplotlib.colorbar.Colorbar">
<emclass="property">class </em><codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">Colorbar</code><spanclass="sig-paren">(</span><em>ax</em>, <em>mappable</em>, <em>**kw</em><spanclass="sig-paren">)</span><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-class docutils literal"><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-class docutils literal"><spanclass="pre">ScalarMappable</span></code></a> such as a
<aclass="reference internal" href="image_api.html#matplotlib.image.AxesImage" title="matplotlib.image.AxesImage"><codeclass="xref py py-class docutils literal"><spanclass="pre">AxesImage</span></code></a> generated via
<p>It is not intended to be instantiated directly; instead,
use <aclass="reference internal" href="figure_api.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-meth docutils literal"><spanclass="pre">colorbar()</span></code></a> or
<aclass="reference internal" href="pyplot_api.html#matplotlib.pyplot.colorbar" title="matplotlib.pyplot.colorbar"><codeclass="xref py py-func docutils literal"><spanclass="pre">colorbar()</span></code></a> to make your colorbar.</p>
<dlclass="method">
<dtid="matplotlib.colorbar.Colorbar.add_lines">
<codeclass="descname">add_lines</code><spanclass="sig-paren">(</span><em>CS</em>, <em>erase=True</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.add_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Add the lines from a non-filled
<codeclass="xref py py-class docutils literal"><spanclass="pre">ContourSet</span></code> to the colorbar.</p>
<p>Set <em>erase</em> to False if these lines should be added to
<codeclass="descname">on_mappable_changed</code><spanclass="sig-paren">(</span><em>mappable</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.on_mappable_changed" title="Permalink to this definition">¶</a></dt>
<dd><p>Updates 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"><spanclass="pre">colorbar_factory()</span></code></a> and should not be called manually.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.colorbar.Colorbar.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove this colorbar from the figure. If the colorbar was created with
<codeclass="docutils literal"><spanclass="pre">use_gridspec=True</span></code> then restore the gridspec to its previous value.</p>
<codeclass="descname">update_bruteforce</code><spanclass="sig-paren">(</span><em>mappable</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.update_bruteforce" title="Permalink to this definition">¶</a></dt>
<dd><p>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
<codeclass="descname">update_normal</code><spanclass="sig-paren">(</span><em>mappable</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.Colorbar.update_normal" title="Permalink to this definition">¶</a></dt>
<dd><p>update solid, lines, etc. Unlike update_bruteforce, it does
not clear the axes. This is meant to be called when the image
or contour plot to which this colorbar belongs is changed.</p>
<p>This is a base class for the <aclass="reference internal" href="#matplotlib.colorbar.Colorbar" title="matplotlib.colorbar.Colorbar"><codeclass="xref py py-class docutils literal"><spanclass="pre">Colorbar</span></code></a> class, which is the
basis for the <aclass="reference internal" href="pyplot_api.html#matplotlib.pyplot.colorbar" title="matplotlib.pyplot.colorbar"><codeclass="xref py py-func docutils literal"><spanclass="pre">colorbar()</span></code></a> function and the
<aclass="reference internal" href="figure_api.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-meth docutils literal"><spanclass="pre">colorbar()</span></code></a> method, which are the
usual ways of creating a colorbar.</p>
<p>It is also useful by itself for showing a colormap. 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>
<codeclass="descname">add_lines</code><spanclass="sig-paren">(</span><em>levels</em>, <em>colors</em>, <em>linewidths</em>, <em>erase=True</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.add_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw lines on the colorbar.</p>
<p><em>colors</em> and <em>linewidths</em> must be scalars or
sequences the same length as <em>levels</em>.</p>
<p>Set <em>erase</em> to False to add lines without first
removing any previously added lines.</p>
</dd></dl>
<dlclass="attribute">
<dtid="matplotlib.colorbar.ColorbarBase.ax">
<codeclass="descname">ax</code><emclass="property"> = None</em><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.ax" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">config_axis</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.config_axis" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">draw_all</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><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">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="method">
<dtid="matplotlib.colorbar.ColorbarBase.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.remove" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">set_alpha</code><spanclass="sig-paren">(</span><em>alpha</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_alpha" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">set_label</code><spanclass="sig-paren">(</span><em>label</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_label" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">set_ticklabels</code><spanclass="sig-paren">(</span><em>ticklabels</em>, <em>update_ticks=True</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_ticklabels" title="Permalink to this definition">¶</a></dt>
<dd><p>set tick labels. Tick labels are updated immediately unless
update_ticks is <em>False</em>. To manually update the ticks, call
<codeclass="descname">set_ticks</code><spanclass="sig-paren">(</span><em>ticks</em>, <em>update_ticks=True</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarBase.set_ticks" title="Permalink to this definition">¶</a></dt>
<dd><p>set tick locations. Tick locations are updated immediately unless
update_ticks is <em>False</em>. To manually update the ticks, call
<codeclass="descname">update_ticks</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><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="class">
<dtid="matplotlib.colorbar.ColorbarPatch">
<emclass="property">class </em><codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">ColorbarPatch</code><spanclass="sig-paren">(</span><em>ax</em>, <em>mappable</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.ColorbarPatch" title="Permalink to this definition">¶</a></dt>
<p>A Colorbar which is created using <aclass="reference internal" href="patches_api.html#matplotlib.patches.Patch" title="matplotlib.patches.Patch"><codeclass="xref py py-class docutils literal"><spanclass="pre">Patch</span></code></a>
rather than the default <codeclass="xref py py-func docutils literal"><spanclass="pre">pcolor()</span></code>.</p>
<p>It uses a list of Patch instances instead of a
<aclass="reference internal" href="collections_api.html#matplotlib.collections.PatchCollection" title="matplotlib.collections.PatchCollection"><codeclass="xref py py-class docutils literal"><spanclass="pre">PatchCollection</span></code></a> because the
latter does not allow the hatch pattern to vary among the
members of the collection.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colorbar.colorbar_factory">
<codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">colorbar_factory</code><spanclass="sig-paren">(</span><em>cax</em>, <em>mappable</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.colorbar_factory" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a colorbar on the given axes for the given mappable.</p>
<p>Typically, for automatic colorbar placement given only a mappable use
<p>Keyword arguments may include the following (with defaults):</p>
<blockquote>
<div><dlclass="docutils">
<dt>location</dt>
<spanclass="classifier-delimiter">:</span><spanclass="classifier">[None|’left’|’right’|’top’|’bottom’]</span><dd>The position, relative to <strong>parents</strong>, where the colorbar axes
should be created. If None, the value will either come from the
given <codeclass="docutils literal"><spanclass="pre">orientation</span></code>, else it will default to ‘right’.</dd>
<dt>orientation</dt>
<spanclass="classifier-delimiter">:</span><spanclass="classifier">[None|’vertical’|’horizontal’]</span><dd>The orientation of the colorbar. Typically, this keyword shouldn’t
be used, as it can be derived from the <codeclass="docutils literal"><spanclass="pre">location</span></code> keyword.</dd>
</dl>
</div></blockquote>
<tableborder="1" class="docutils">
<colgroup>
<colwidth="20%" />
<colwidth="80%" />
</colgroup>
<theadvalign="bottom">
<trclass="row-odd"><thclass="head">Property</th>
<thclass="head">Description</th>
</tr>
</thead>
<tbodyvalign="top">
<trclass="row-even"><td><em>orientation</em></td>
<td>vertical or horizontal</td>
</tr>
<trclass="row-odd"><td><em>fraction</em></td>
<td>0.15; fraction of original axes to use for colorbar</td>
</tr>
<trclass="row-even"><td><em>pad</em></td>
<td>0.05 if vertical, 0.15 if horizontal; fraction
of original axes between colorbar and new image axes</td>
</tr>
<trclass="row-odd"><td><em>shrink</em></td>
<td>1.0; fraction by which to shrink the colorbar</td>
</tr>
<trclass="row-even"><td><em>aspect</em></td>
<td>20; ratio of long to short dimensions</td>
</tr>
<trclass="row-odd"><td><em>anchor</em></td>
<td>(0.0, 0.5) if vertical; (0.5, 1.0) if horizontal;
the anchor point of the colorbar axes</td>
</tr>
<trclass="row-even"><td><em>panchor</em></td>
<td>(1.0, 0.5) if vertical; (0.5, 0.0) if horizontal;
the anchor point of the colorbar parent axes. If
False, the parent axes’ anchor will be unchanged</td>
</tr>
</tbody>
</table>
<p>Returns (cax, kw), the child axes and the reduced kw dictionary to be
passed when creating the colorbar instance.</p>
</dd></dl>
<dlclass="function">
<dtid="matplotlib.colorbar.make_axes_gridspec">
<codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">make_axes_gridspec</code><spanclass="sig-paren">(</span><em>parent</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.colorbar.make_axes_gridspec" title="Permalink to this definition">¶</a></dt>
<dd><p>Resize and reposition a parent axes, and return a child axes
suitable for a colorbar. This function is similar to
make_axes. Prmary differences are</p>
<blockquote>
<div><ul>
<li><pclass="first"><em>make_axes_gridspec</em> only handles the <em>orientation</em> keyword
and cannot handle the “location” keyword.</p>
</li>
<li><pclass="first"><em>make_axes_gridspec</em> should only be used with a subplot parent.</p>
</li>
<li><dlclass="first docutils">
<dt><em>make_axes</em> creates an instance of Axes. <em>make_axes_gridspec</em></dt>
<dd><pclass="first last">creates an instance of Subplot.</p>
</dd>
</dl>
</li>
<li><dlclass="first docutils">
<dt><em>make_axes</em> updates the position of the</dt>
<dd><pclass="first last">parent. <em>make_axes_gridspec</em> replaces the grid_spec attribute
of the parent with a new one.</p>
</dd>
</dl>
</li>
</ul>
</div></blockquote>
<p>While this function is meant to be compatible with <em>make_axes</em>,