<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/tight_layout_api.html">https://matplotlib.org/stable/api/tight_layout_api.html</a></div>
<spanid="matplotlib-tight-layout"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.tight_layout</span></code><aclass="headerlink" href="#module-matplotlib.tight_layout" title="Permalink to this headline">¶</a></h1>
<p>Routines to adjust subplot params so that subplots are
nicely fit in the figure. In doing so, only axis labels, tick labels, axes
titles and offsetboxes that are anchored to axes are currently considered.</p>
<p>Internally, this module assumes that the margins (left_margin, etc.) which are
differences between ax.get_tightbbox and ax.bbox are independent of axes
position. This may fail if Axes.adjustable is datalim. Also, This will fail
for some cases (for example, left or right margin is affected by xlabel).</p>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><dlclass="first last docutils">
<dt><strong>nrows_ncols</strong><spanclass="classifier">Tuple[int, int]</span></dt><dd><p>Number of rows and number of columns of the grid.</p>
</dd>
<dt><strong>num1num2_list</strong><spanclass="classifier">List[int]</span></dt><dd><p>List of numbers specifying the area occupied by the subplot</p>
</dd>
<dt><strong>subplot_list</strong><spanclass="classifier">list of subplots</span></dt><dd><p>List of subplots that will be used to calculate optimal subplot_params.</p>
</dd>
<dt><strong>pad</strong><spanclass="classifier">float</span></dt><dd><p>Padding between the figure edge and the edges of subplots, as a
fraction of the font size.</p>
</dd>
<dt><strong>h_pad, w_pad</strong><spanclass="classifier">float</span></dt><dd><p>Padding (height/width) between edges of adjacent subplots, as a
fraction of the font size. Defaults to <em>pad</em>.</p>
<codeclass="descclassname">matplotlib.tight_layout.</code><codeclass="descname">get_renderer</code><spanclass="sig-paren">(</span><em><spanclass="n">fig</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tight_layout.html#get_renderer"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tight_layout.get_renderer" title="Permalink to this definition">¶</a></dt>
<codeclass="descclassname">matplotlib.tight_layout.</code><codeclass="descname">get_subplotspec_list</code><spanclass="sig-paren">(</span><em><spanclass="n">axes_list</span></em>, <em><spanclass="n">grid_spec</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/tight_layout.html#get_subplotspec_list"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.tight_layout.get_subplotspec_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of subplotspec from the given list of axes.</p>
<p>For an instance of axes that does not support subplotspec, None is inserted
in the list.</p>
<p>If grid_spec is given, None is inserted for those not from the given
<dt><strong>axes_list</strong><spanclass="classifier">list of Axes</span></dt><dd></dd>
<dt><strong>subplotspec_list</strong><spanclass="classifier">list of <aclass="reference internal" href="_as_gen/matplotlib.gridspec.SubplotSpec.html#matplotlib.gridspec.SubplotSpec" title="matplotlib.gridspec.SubplotSpec"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">SubplotSpec</span></code></a></span></dt><dd><p>The subplotspecs of each axes.</p>
<dt><strong>pad</strong><spanclass="classifier">float</span></dt><dd><p>Padding between the figure edge and the edges of subplots, as a
fraction of the font size.</p>
</dd>
<dt><strong>h_pad, w_pad</strong><spanclass="classifier">float</span></dt><dd><p>Padding (height/width) between edges of adjacent subplots. Defaults to
that the whole subplots area (including labels) will fit into.
Defaults to using the entire figure.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<dt>subplotspec or None</dt><dd><p>subplotspec kwargs to be passed to <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure.subplots_adjust" title="matplotlib.figure.Figure.subplots_adjust"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure.subplots_adjust</span></code></a> or
None if tight_layout could not be accomplished.</p>