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
<spanid="matplotlib-table"></span><h1><codeclass="docutils literal notranslate"><spanclass="pre">matplotlib.table</span></code><aclass="headerlink" href="#module-matplotlib.table" title="Permalink to this headline">¶</a></h1>
<p>This module provides functionality to add a table to a plot.</p>
<p>Use the factory function <aclass="reference internal" href="#matplotlib.table.table" title="matplotlib.table.table"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">table</span></code></a> to create a ready-made
table from texts. If you need more control, use the <aclass="reference internal" href="#matplotlib.table.Table" title="matplotlib.table.Table"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Table</span></code></a> class and its
methods.</p>
<p>The table consists of a grid of cells, which are indexed by (row, column).
The cell (0, 0) is positioned at the top left.</p>
<p>Thanks to John Gill for providing the class and table.</p>
<dlclass="class">
<dtid="matplotlib.table.Cell">
<emclass="property">class </em><codeclass="descclassname">matplotlib.table.</code><codeclass="descname">Cell</code><spanclass="sig-paren">(</span><em>xy</em>, <em>width</em>, <em>height</em>, <em>edgecolor='k'</em>, <em>facecolor='w'</em>, <em>fill=True</em>, <em>text=''</em>, <em>loc=None</em>, <em>fontproperties=None</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell" title="Permalink to this definition">¶</a></dt>
<dd><pclass="first last">A dict defining the font properties of the text. Supported keys and
values are the keyword arguments accepted by <aclass="reference internal" href="font_manager_api.html#matplotlib.font_manager.FontProperties" title="matplotlib.font_manager.FontProperties"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">FontProperties</span></code></a>.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<dlclass="attribute">
<dtid="matplotlib.table.Cell.PAD">
<codeclass="descname">PAD</code><emclass="property"> = 0.1</em><aclass="headerlink" href="#matplotlib.table.Cell.PAD" title="Permalink to this definition">¶</a></dt>
<dd><p>Padding between text and rectangle.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.auto_set_font_size">
<codeclass="descname">auto_set_font_size</code><spanclass="sig-paren">(</span><em>self</em>, <em>renderer</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.auto_set_font_size"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.auto_set_font_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Shrink font size until the text fits into the cell width.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.draw">
<codeclass="descname">draw</code><spanclass="sig-paren">(</span><em>self</em>, <em>renderer</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.draw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.draw" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw the <codeclass="xref py py-class docutils literal notranslate"><spanclass="pre">Patch</span></code> to the given <em>renderer</em>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.get_fontsize">
<codeclass="descname">get_fontsize</code><spanclass="sig-paren">(</span><em>self</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.get_fontsize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.get_fontsize" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the cell fontsize.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.get_required_width">
<codeclass="descname">get_required_width</code><spanclass="sig-paren">(</span><em>self</em>, <em>renderer</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.get_required_width"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.get_required_width" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the minimal required width for the cell.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.get_text">
<codeclass="descname">get_text</code><spanclass="sig-paren">(</span><em>self</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.get_text"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.get_text" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">get_text_bounds</code><spanclass="sig-paren">(</span><em>self</em>, <em>renderer</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.get_text_bounds"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.get_text_bounds" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the text bounds as <em>(x, y, width, height)</em> in table coordinates.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.set_figure">
<codeclass="descname">set_figure</code><spanclass="sig-paren">(</span><em>self</em>, <em>fig</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.set_figure"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.set_figure" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the <aclass="reference internal" href="_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Figure</span></code></a> instance the artist belongs to.</p>
<codeclass="descname">set_fontsize</code><spanclass="sig-paren">(</span><em>self</em>, <em>size</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.set_fontsize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.set_fontsize" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the text fontsize.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Cell.set_text_props">
<codeclass="descname">set_text_props</code><spanclass="sig-paren">(</span><em>self</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.set_text_props"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.set_text_props" title="Permalink to this definition">¶</a></dt>
<td>{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}</td>
<codeclass="descname">set_transform</code><spanclass="sig-paren">(</span><em>self</em>, <em>trans</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Cell.set_transform"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Cell.set_transform" title="Permalink to this definition">¶</a></dt>
<codeclass="descname">get_path</code><spanclass="sig-paren">(</span><em>self</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#CustomCell.get_path"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.CustomCell.get_path" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <aclass="reference internal" href="path_api.html#matplotlib.path.Path" title="matplotlib.path.Path"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Path</span></code></a> for the <aclass="reference internal" href="#matplotlib.table.CustomCell.visible_edges" title="matplotlib.table.CustomCell.visible_edges"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">visible_edges</span></code></a>.</p>
<codeclass="descname">visible_edges</code><aclass="headerlink" href="#matplotlib.table.CustomCell.visible_edges" title="Permalink to this definition">¶</a></dt>
<dd><p>The cell edges to be drawn with a line.</p>
<p>Reading this property returns a substring of 'BRTL' (bottom, right,
top, left').</p>
<p>When setting this property, you can use a substring of 'BRTL' or one
of {'open', 'closed', 'horizontal', 'vertical'}.</p>
</dd></dl>
</dd></dl>
<dlclass="class">
<dtid="matplotlib.table.Table">
<emclass="property">class </em><codeclass="descclassname">matplotlib.table.</code><codeclass="descname">Table</code><spanclass="sig-paren">(</span><em>ax</em>, <em>loc=None</em>, <em>bbox=None</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table" title="Permalink to this definition">¶</a></dt>
<p>The table consists of a grid of cells, which are indexed by (row, column).</p>
<p>For a simple table, you'll have a full grid of cells with indices from
(0, 0) to (num_rows-1, num_cols-1), in which the cell (0, 0) is positioned
at the top left. However, you can also add cells with negative indices.
You don't have to add a cell to every grid position, so you can create
tables that have holes.</p>
<p><em>Note</em>: You'll usually not create an empty table from scratch. Instead use
<aclass="reference internal" href="#matplotlib.table.table" title="matplotlib.table.table"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">table</span></code></a> to create a table from data.</p>
<codeclass="descname">AXESPAD</code><emclass="property"> = 0.02</em><aclass="headerlink" href="#matplotlib.table.Table.AXESPAD" title="Permalink to this definition">¶</a></dt>
<dd><p>The border between the Axes and the table edge in Axes units.</p>
</dd></dl>
<dlclass="attribute">
<dtid="matplotlib.table.Table.FONTSIZE">
<codeclass="descname">FONTSIZE</code><emclass="property"> = 10</em><aclass="headerlink" href="#matplotlib.table.Table.FONTSIZE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Table.add_cell">
<codeclass="descname">add_cell</code><spanclass="sig-paren">(</span><em>self</em>, <em>row</em>, <em>col</em>, <em>*args</em>, <em>**kwargs</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.add_cell"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.add_cell" title="Permalink to this definition">¶</a></dt>
<dd><pclass="first last">All other parameters are passed on to <aclass="reference internal" href="#matplotlib.table.Cell" title="matplotlib.table.Cell"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Cell</span></code></a>.</p>
</dd>
</dl>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><dlclass="first last docutils">
<codeclass="descname">auto_set_column_width</code><spanclass="sig-paren">(</span><em>self</em>, <em>col</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.auto_set_column_width"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.auto_set_column_width" title="Permalink to this definition">¶</a></dt>
<dd><p>Automatically set the widths of given columns to optimal sizes.</p>
<codeclass="descname">auto_set_font_size</code><spanclass="sig-paren">(</span><em>self</em>, <em>value=True</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.auto_set_font_size"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.auto_set_font_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Possible values where to place the table relative to the Axes.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Table.contains">
<codeclass="descname">contains</code><spanclass="sig-paren">(</span><em>self</em>, <em>mouseevent</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.contains"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Test whether the artist contains the mouse event.</p>
<codeclass="descname">draw</code><spanclass="sig-paren">(</span><em>self</em>, <em>renderer</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.draw"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.draw" title="Permalink to this definition">¶</a></dt>
<dd><p>Draw the Artist using the given renderer.</p>
<p>This method will be overridden in the Artist subclasses. Typically,
it is implemented to not have any effect if the Artist is not visible
<codeclass="descname">get_celld</code><spanclass="sig-paren">(</span><em>self</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.get_celld"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.get_celld" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a dict of cells in the table mapping <em>(row, column)</em> to
<codeclass="descname">get_child_artists</code><spanclass="sig-paren">(</span><em>self</em><spanclass="sig-paren">)</span><aclass="headerlink" href="#matplotlib.table.Table.get_child_artists" title="Permalink to this definition">¶</a></dt>
<dd><p>[<em>Deprecated</em>] Return the Artists contained by the table.</p>
<pclass="rubric">Notes</p>
<divclass="deprecated">
<p><spanclass="versionmodified">Deprecated since version 3.0.</span></p>
</div>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Table.get_children">
<codeclass="descname">get_children</code><spanclass="sig-paren">(</span><em>self</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.get_children"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.get_children" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the Artists contained by the table.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Table.get_window_extent">
<codeclass="descname">get_window_extent</code><spanclass="sig-paren">(</span><em>self</em>, <em>renderer</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.get_window_extent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.get_window_extent" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the bounding box of the table in window coords.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Table.scale">
<codeclass="descname">scale</code><spanclass="sig-paren">(</span><em>self</em>, <em>xscale</em>, <em>yscale</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.scale"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.scale" title="Permalink to this definition">¶</a></dt>
<dd><p>Scale column widths by <em>xscale</em> and row heights by <em>yscale</em>.</p>
</dd></dl>
<dlclass="method">
<dtid="matplotlib.table.Table.set_fontsize">
<codeclass="descname">set_fontsize</code><spanclass="sig-paren">(</span><em>self</em>, <em>size</em><spanclass="sig-paren">)</span><aclass="reference internal" href="../_modules/matplotlib/table.html#Table.set_fontsize"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink" href="#matplotlib.table.Table.set_fontsize" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the font size, in points, of the cell text.</p>
<p>As long as auto font size has not been disabled, the value will be
clipped such that the text fits horizontally into the cell.</p>
<p>You can disable this behavior using <aclass="reference internal" href="#matplotlib.table.Table.auto_set_font_size" title="matplotlib.table.Table.auto_set_font_size"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">auto_set_font_size</span></code></a>.</p>
<dd><p>Add a table to 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>.</p>
<p>At least one of <em>cellText</em> or <em>cellColours</em> must be specified. These
parameters must be 2D lists, in which the outer lists define the rows and
the inner list define the column values per row. Each row must have the
same number of elements.</p>
<p>The table can optionally have row and column headers, which are configured
using <em>rowLabels</em>, <em>rowColours</em>, <em>rowLoc</em> and <em>colLabels</em>, <em>colColours</em>,
<em>colLoc</em> respectively.</p>
<p>For finer grained control over tables, use the <aclass="reference internal" href="#matplotlib.table.Table" title="matplotlib.table.Table"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Table</span></code></a> class and add it to
the axes with <aclass="reference internal" href="_as_gen/matplotlib.axes.Axes.add_table.html#matplotlib.axes.Axes.add_table" title="matplotlib.axes.Axes.add_table"><codeclass="xref py py-obj docutils literal notranslate"><spanclass="pre">Axes.add_table</span></code></a>.</p>
<dt><strong>cellText</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">2D list of str, optional</span></dt>
<dd><pclass="first">The texts to place into the table cells.</p>
<pclass="last"><em>Note</em>: Line breaks in the strings are currently not accounted for and
will result in the text exceeding the cell boundaries.</p>
</dd>
<dt><strong>cellColours</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">2D list of matplotlib color specs, optional</span></dt>
<dd><pclass="first last">The background colors of the cells.</p>
<dd><pclass="first last">A bounding box to draw the table into. If this is not <em>None</em>, this
overrides <em>loc</em>.</p>
</dd>
<dt><strong>edges</strong><spanclass="classifier-delimiter">:</span><spanclass="classifier">substring of 'BRTL' or {'open', 'closed', 'horizontal', 'vertical'}</span></dt>
<dd><pclass="first last">The cell edges to be drawn with a line. See also