You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
<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/figure_api.html">https://matplotlib.org/stable/api/figure_api.html</a></div>
<dd>top level container for all plot elements</dd>
</dl>
<dlclass="class">
<dtid="matplotlib.figure.AxesStack">
<emclass="property">class </em><codeclass="descclassname">matplotlib.figure.</code><codeclass="descname">AxesStack</code><aclass="headerlink" href="#matplotlib.figure.AxesStack" title="Permalink to this definition">¶</a></dt>
<p>Specialization of the Stack to handle all tracking of Axes in a Figure.
This stack stores <codeclass="docutils literal"><spanclass="pre">key,</span><spanclass="pre">(ind,</span><spanclass="pre">axes)</span></code> pairs, where:</p>
<blockquote>
<div><ulclass="simple">
<li><strong>key</strong> should be a hash of the args and kwargs
used in generating the Axes.</li>
<li><strong>ind</strong> is a serial number for tracking the order
in which axes were added.</li>
</ul>
</div></blockquote>
<p>The AxesStack is a callable, where <codeclass="docutils literal"><spanclass="pre">ax_stack()</span></code> returns
the current axes. Alternatively the <aclass="reference internal" href="#matplotlib.figure.AxesStack.current_key_axes" title="matplotlib.figure.AxesStack.current_key_axes"><codeclass="xref py py-meth docutils literal"><spanclass="pre">current_key_axes()</span></code></a> will
return the current key and associated axes.</p>
<dlclass="method">
<dtid="matplotlib.figure.AxesStack.add">
<codeclass="descname">add</code><spanclass="sig-paren">(</span><em>key</em>, <em>a</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.AxesStack.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add Axes <em>a</em>, with key <em>key</em>, to the stack, and return the stack.</p>
<p>If <em>a</em> is already on the stack, don’t add it again, but
return <em>None</em>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.AxesStack.as_list">
<codeclass="descname">as_list</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.AxesStack.as_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of the Axes instances that have been added to the figure</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.AxesStack.bubble">
<codeclass="descname">bubble</code><spanclass="sig-paren">(</span><em>a</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.AxesStack.bubble" title="Permalink to this definition">¶</a></dt>
<dd><p>Move the given axes, which must already exist in the
<codeclass="descname">current_key_axes</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.AxesStack.current_key_axes" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a tuple of <codeclass="docutils literal"><spanclass="pre">(key,</span><spanclass="pre">axes)</span></code> for the active axes.</p>
<p>If no axes exists on the stack, then returns <codeclass="docutils literal"><spanclass="pre">(None,</span><spanclass="pre">None)</span></code>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.AxesStack.get">
<codeclass="descname">get</code><spanclass="sig-paren">(</span><em>key</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.AxesStack.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Axes instance that was added with <em>key</em>.
If it is not present, return None.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.AxesStack.remove">
<codeclass="descname">remove</code><spanclass="sig-paren">(</span><em>a</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.AxesStack.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove the axes from the stack.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.figure.Figure">
<emclass="property">class </em><codeclass="descclassname">matplotlib.figure.</code><codeclass="descname">Figure</code><spanclass="sig-paren">(</span><em>figsize=None</em>, <em>dpi=None</em>, <em>facecolor=None</em>, <em>edgecolor=None</em>, <em>linewidth=0.0</em>, <em>frameon=None</em>, <em>subplotpars=None</em>, <em>tight_layout=None</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure" title="Permalink to this definition">¶</a></dt>
<p>The Figure instance supports callbacks through a <em>callbacks</em>
attribute which is a <aclass="reference internal" href="cbook_api.html#matplotlib.cbook.CallbackRegistry" title="matplotlib.cbook.CallbackRegistry"><codeclass="xref py py-class docutils literal"><spanclass="pre">matplotlib.cbook.CallbackRegistry</span></code></a>
instance. The events you can connect to are ‘dpi_changed’, and
the callback will be called with <codeclass="docutils literal"><spanclass="pre">func(fig)</span></code> where fig is the
<dd>If <em>False</em> use <em>subplotpars</em>; if <em>True</em> adjust subplot
parameters using <aclass="reference internal" href="#matplotlib.figure.Figure.tight_layout" title="matplotlib.figure.Figure.tight_layout"><codeclass="xref py py-meth docutils literal"><spanclass="pre">tight_layout()</span></code></a> with default padding.
When providing a dict containing the keys <codeclass="xref py py-obj docutils literal"><spanclass="pre">pad</span></code>, <codeclass="xref py py-obj docutils literal"><spanclass="pre">w_pad</span></code>, <codeclass="xref py py-obj docutils literal"><spanclass="pre">h_pad</span></code>
and <codeclass="xref py py-obj docutils literal"><spanclass="pre">rect</span></code>, the default <aclass="reference internal" href="#matplotlib.figure.Figure.tight_layout" title="matplotlib.figure.Figure.tight_layout"><codeclass="xref py py-meth docutils literal"><spanclass="pre">tight_layout()</span></code></a> paddings will be
overridden.
Defaults to rc <codeclass="docutils literal"><spanclass="pre">figure.autolayout</span></code>.</dd>
</dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.add_axes">
<codeclass="descname">add_axes</code><spanclass="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.add_axes" title="Permalink to this definition">¶</a></dt>
<dd><p>Add an axes at position <em>rect</em> [<em>left</em>, <em>bottom</em>, <em>width</em>,
<em>height</em>] where all quantities are in fractions of figure
width and height. kwargs are legal
<aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal"><spanclass="pre">Axes</span></code></a> kwargs plus <em>projection</em> which
sets the projection type of the axes. (For backward
compatibility, <codeclass="docutils literal"><spanclass="pre">polar=True</span></code> may also be provided, which is
equivalent to <codeclass="docutils literal"><spanclass="pre">projection='polar'</span></code>). Valid values for
<em>projection</em> are: [‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’]. Some of these
projections support additional kwargs, which may be provided
<p>In rare circumstances, add_axes may be called with a single
argument, an Axes instance already created in the present
figure but not in the figure’s list of axes. For example,
if an axes has been removed with <aclass="reference internal" href="#matplotlib.figure.Figure.delaxes" title="matplotlib.figure.Figure.delaxes"><codeclass="xref py py-meth docutils literal"><spanclass="pre">delaxes()</span></code></a>, it can
<codeclass="descname">add_axobserver</code><spanclass="sig-paren">(</span><em>func</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.add_axobserver" title="Permalink to this definition">¶</a></dt>
<dd><p>whenever the axes state change, <codeclass="docutils literal"><spanclass="pre">func(self)</span></code> will be called</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.add_subplot">
<codeclass="descname">add_subplot</code><spanclass="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.add_subplot" title="Permalink to this definition">¶</a></dt>
<p><em>kwargs</em> are legal <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal"><spanclass="pre">Axes</span></code></a> kwargs plus
<em>projection</em>, which chooses a projection type for the axes.
(For backward compatibility, <em>polar=True</em> may also be
provided, which is equivalent to <em>projection=’polar’</em>). Valid
values for <em>projection</em> are: [‘aitoff’, ‘hammer’, ‘lambert’, ‘mollweide’, ‘polar’, ‘rectilinear’]. Some of
these projections
support additional <em>kwargs</em>, which may be provided to
<p>The <aclass="reference internal" href="axes_api.html#matplotlib.axes.Axes" title="matplotlib.axes.Axes"><codeclass="xref py py-class docutils literal"><spanclass="pre">Axes</span></code></a> instance will be returned.</p>
<p>If the figure already has a subplot with key (<em>args</em>,
<em>kwargs</em>) then it will simply make that subplot current and
return it.</p>
<divclass="admonition seealso">
<pclass="first admonition-title">See also</p>
<pclass="last"><aclass="reference internal" href="pyplot_api.html#matplotlib.pyplot.subplot" title="matplotlib.pyplot.subplot"><codeclass="xref py py-meth docutils literal"><spanclass="pre">subplot()</span></code></a> for an
<codeclass="descname">autofmt_xdate</code><spanclass="sig-paren">(</span><em>bottom=0.2</em>, <em>rotation=30</em>, <em>ha='right'</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.autofmt_xdate" title="Permalink to this definition">¶</a></dt>
<dd><p>Date ticklabels often overlap, so it is useful to rotate them
and right align them. Also, a common use case is a number of
subplots with shared xaxes where the x-axis is date data. The
ticklabels are often long, and it helps to rotate them on the
bottom subplot and turn them off on other subplots, as well as
turn off xlabels.</p>
<dlclass="docutils">
<dt><em>bottom</em></dt>
<dd>The bottom of the subplots for <aclass="reference internal" href="#matplotlib.figure.Figure.subplots_adjust" title="matplotlib.figure.Figure.subplots_adjust"><codeclass="xref py py-meth docutils literal"><spanclass="pre">subplots_adjust()</span></code></a></dd>
<dt><em>rotation</em></dt>
<dd>The rotation of the xtick labels</dd>
<dt><em>ha</em></dt>
<dd>The horizontal alignment of the xticklabels</dd>
</dl>
</dd></dl>
<dlclass="attribute">
<dtid="matplotlib.figure.Figure.axes">
<codeclass="descname">axes</code><aclass="headerlink" href="#matplotlib.figure.Figure.axes" title="Permalink to this definition">¶</a></dt>
<dd><p>Read-only: list of axes in Figure</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.clear">
<codeclass="descname">clear</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear the figure – synonym for <aclass="reference internal" href="#matplotlib.figure.Figure.clf" title="matplotlib.figure.Figure.clf"><codeclass="xref py py-meth docutils literal"><spanclass="pre">clf()</span></code></a>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.clf">
<codeclass="descname">clf</code><spanclass="sig-paren">(</span><em>keep_observers=False</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.clf" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear the figure.</p>
<p>Set <em>keep_observers</em> to True if, for example,
a gui widget is tracking the axes in the figure.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.colorbar">
<codeclass="descname">colorbar</code><spanclass="sig-paren">(</span><em>mappable</em>, <em>cax=None</em>, <em>ax=None</em>, <em>use_gridspec=True</em>, <em>**kw</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.colorbar" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a colorbar for a ScalarMappable instance, <em>mappable</em>.</p>
<p>Documentation for the pylab thin wrapper:</p>
<p>Add a colorbar to a plot.</p>
<p>Function signatures for the <aclass="reference internal" href="pyplot_api.html#module-matplotlib.pyplot" title="matplotlib.pyplot"><codeclass="xref py py-mod docutils literal"><spanclass="pre">pyplot</span></code></a> interface; all
<codeclass="xref py py-class docutils literal"><spanclass="pre">ContourSet</span></code>, etc. to
which the colorbar applies; this argument is mandatory for the
<aclass="reference internal" href="#matplotlib.figure.Figure.colorbar" title="matplotlib.figure.Figure.colorbar"><codeclass="xref py py-meth docutils literal"><spanclass="pre">colorbar()</span></code></a> method but optional 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, which sets the
default to the current image.</dd>
</dl>
</div></blockquote>
<p>keyword arguments:</p>
<blockquote>
<div><dlclass="docutils">
<dt><em>cax</em></dt>
<dd>None | axes object into which the colorbar will be drawn</dd>
<dt><em>ax</em></dt>
<dd>None | parent axes object(s) from which space for a new
colorbar axes will be stolen. If a list of axes is given
they will all be resized to make room for the colorbar axes.</dd>
<dt><em>use_gridspec</em></dt>
<dd>False | If <em>cax</em> is None, a new <em>cax</em> is created as an instance of
Axes. If <em>ax</em> is an instance of Subplot and <em>use_gridspec</em> is True,
<em>cax</em> is created as an instance of Subplot using the
grid_spec module.</dd>
</dl>
</div></blockquote>
<p>Additional keyword arguments are of two kinds:</p>
<blockquote>
<div><p>axes properties:</p>
<blockquote>
<div><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>
<p>However this has negative consequences in other circumstances. Particularly
with semi transparent images (alpha < 1) and colorbar extensions and is not
enabled by default see (issue #1188).</p>
<dlclass="docutils">
<dt>returns:</dt>
<dd><aclass="reference internal" href="colorbar_api.html#matplotlib.colorbar.Colorbar" title="matplotlib.colorbar.Colorbar"><codeclass="xref py py-class docutils literal"><spanclass="pre">Colorbar</span></code></a> instance; see also its base class,
<aclass="reference internal" href="colorbar_api.html#matplotlib.colorbar.ColorbarBase" title="matplotlib.colorbar.ColorbarBase"><codeclass="xref py py-class docutils literal"><spanclass="pre">ColorbarBase</span></code></a>. Call the
<codeclass="descname">contains</code><spanclass="sig-paren">(</span><em>mouseevent</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Test whether the mouse event occurred on the figure.</p>
<p>Returns True,{}</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.delaxes">
<codeclass="descname">delaxes</code><spanclass="sig-paren">(</span><em>a</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.delaxes" title="Permalink to this definition">¶</a></dt>
<dd><p>remove a from the figure and update the current axes</p>
</dd></dl>
<dlclass="attribute">
<dtid="matplotlib.figure.Figure.dpi">
<codeclass="descname">dpi</code><aclass="headerlink" href="#matplotlib.figure.Figure.dpi" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.draw">
<codeclass="descname">draw</code><spanclass="sig-paren">(</span><em>artist</em>, <em>renderer</em>, <em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.draw" title="Permalink to this definition">¶</a></dt>
<dd><p>Render the figure using <aclass="reference internal" href="backend_bases_api.html#matplotlib.backend_bases.RendererBase" title="matplotlib.backend_bases.RendererBase"><codeclass="xref py py-class docutils literal"><spanclass="pre">matplotlib.backend_bases.RendererBase</span></code></a>
instance <em>renderer</em>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.figure.Figure.draw_artist">
<codeclass="descname">draw_artist</code><spanclass="sig-paren">(</span><em>a</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.figure.Figure.draw_artist" title="Permalink to this definition">¶</a></dt>