<divid="unreleased-message"> You are reading an old version of the documentation (v3.2.0). 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>Colorbar toolkit with two classes and a function:</p>
<blockquote>
<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>the derived class for use with images or contour plots.</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>a function for resizing an axes and adding a second axes
and <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>; the <aclass="reference internal" href="_as_gen/matplotlib.pyplot.colorbar.html#matplotlib.pyplot.colorbar" title="matplotlib.pyplot.colorbar"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">colorbar()</span></code></a> function
is a thin wrapper over <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-meth docutils literal notranslate"><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="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-class 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-class docutils literal notranslate"><spanclass="pre">ScalarMappable</span></code></a> such as a
<p>It 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-meth docutils literal notranslate"><spanclass="pre">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-func docutils literal notranslate"><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>self</em>, <em>CS</em>, <em>erase=True</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-class docutils literal notranslate"><spanclass="pre">ContourSet</span></code></a> 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>self</em>, <em>mappable</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>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 notranslate"><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><em>self</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. If the colorbar was created with
<codeclass="docutils literal notranslate"><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>self</em>, <em>mappable</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>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>self</em>, <em>mappable</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>Unlike <aclass="reference internal" href="#matplotlib.colorbar.Colorbar.update_bruteforce" title="matplotlib.colorbar.Colorbar.update_bruteforce"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">update_bruteforce</span></code></a>, this does not clear the axes. 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>
<codeclass="descname">config_axis</code><spanclass="sig-paren">(</span><em>self</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>
<codeclass="descname">draw_all</code><spanclass="sig-paren">(</span><em>self</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>self</em>, <em>minor=False</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>self</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>Turns off the minor ticks on the colorbar.</p>
<codeclass="descname">minorticks_on</code><spanclass="sig-paren">(</span><em>self</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>Turns on the minor ticks on the colorbar 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="method">
<dtid="matplotlib.colorbar.ColorbarBase.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><em>self</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>self</em>, <em>alpha</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>
<codeclass="descname">set_label</code><spanclass="sig-paren">(</span><em>self</em>, <em>label</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/colorbar.html#ColorbarBase.set_label"><spanclass="viewcode-link">[source]</span></a><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>self</em>, <em>ticklabels</em>, <em>update_ticks=True</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>self</em>, <em>ticks</em>, <em>update_ticks=True</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">{None, sequence, <aclass="reference internal" href="ticker_api.html#matplotlib.ticker.Locator" title="matplotlib.ticker.Locator"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Locator</span></code></a> instance}</span></dt><dd><p>If None, a default Locator will be used.</p>
</dd>
<dt><strong>update_ticks</strong><spanclass="classifier">{True, False}, optional</span></dt><dd><p>If True, tick locations are updated immediately. If False,
use <aclass="reference internal" href="#matplotlib.colorbar.ColorbarBase.update_ticks" title="matplotlib.colorbar.ColorbarBase.update_ticks"><codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">update_ticks()</span></code></a> to manually update the ticks.</p>
<codeclass="descname">update_ticks</code><spanclass="sig-paren">(</span><em>self</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="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="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 which is created using <aclass="reference internal" href="_as_gen/matplotlib.patches.Patch.html#matplotlib.patches.Patch" title="matplotlib.patches.Patch"><codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Patch</span></code></a>
rather than the default <codeclass="xref py py-func docutils literal notranslate"><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 notranslate"><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="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>Creates a colorbar on the given axes for the given mappable.</p>
<p>Typically, for automatic colorbar placement given only a mappable use
<codeclass="descclassname">matplotlib.colorbar.</code><codeclass="descname">make_axes</code><spanclass="sig-paren">(</span><em>parents</em>, <em>location=None</em>, <em>orientation=None</em>, <em>fraction=0.15</em>, <em>shrink=1.0</em>, <em>aspect=20</em>, <em>**kw</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>Resize and reposition parent axes, and return a child
axes suitable for a colorbar.</p>
<p>Keyword arguments may include the following (with defaults):</p>
<blockquote>
<div><dlclass="docutils">
<dt>location<spanclass="classifier">[None|'left'|'right'|'top'|'bottom']</span></dt><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 notranslate"><spanclass="pre">orientation</span></code>, else it will default to 'right'.</dd>
<dt>orientation<spanclass="classifier">[None|'vertical'|'horizontal']</span></dt><dd>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.</dd>
</dl>
</div></blockquote>
<tableborder="1" class="docutils align-default">
<colgroup>
<colwidth="18%" />
<colwidth="82%" />
</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 multiply the size of 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>*</em>, <em>fraction=0.15</em>, <em>shrink=1.0</em>, <em>aspect=20</em>, <em>**kw</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>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><ulclass="simple">
<li><em>make_axes_gridspec</em> only handles the <em>orientation</em> keyword
and cannot handle the "location" keyword.</li>
<li><em>make_axes_gridspec</em> should only be used with a subplot parent.</li>
<li><dlclass="first docutils">
<dt><em>make_axes</em> creates an instance of Axes. <em>make_axes_gridspec</em></dt><dd>creates an instance of Subplot.</dd>
</dl>
</li>
<li><dlclass="first docutils">
<dt><em>make_axes</em> updates the position of the</dt><dd>parent. <em>make_axes_gridspec</em> replaces the grid_spec attribute
of the parent with a new one.</dd>
</dl>
</li>
</ul>
</div></blockquote>
<p>While this function is meant to be compatible with <em>make_axes</em>,
there could be some minor differences.</p>
<p>Keyword arguments may include the following (with defaults):</p>
<blockquote>
<div><dlclass="docutils">
<dt><em>orientation</em></dt><dd>'vertical' or 'horizontal'</dd>
</dl>
</div></blockquote>
<tableborder="1" class="docutils align-default">
<colgroup>
<colwidth="18%" />
<colwidth="82%" />
</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 multiply the size of 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>All but the first of these are stripped from the input kw set.</p>
<p>Returns (cax, kw), the child axes and the reduced kw dictionary to be