table

matplotlib.table

Place a table below the x-axis at location loc.

The table consists of a grid of cells.

The grid need not be rectangular and can have holes.

Cells are added by specifying their row and column.

For the purposes of positioning the cell at (0, 0) is assumed to be at the top left and the cell at (max_row, max_col) is assumed to be at bottom right.

You can add additional cells outside this range to have convenient ways of positioning more interesting grids.

Author : John Gill <jng@europe.renre.com> Copyright : 2004 John Gill and John Hunter License : matplotlib license

class matplotlib.table.Cell(xy, width, height, edgecolor='k', facecolor='w', fill=True, text='', loc=None, fontproperties=None) [source]

Bases: matplotlib.patches.Rectangle

A cell is a Rectangle with some associated text.

PAD = 0.1
auto_set_font_size(renderer) [source]

Shrink font size until text fits.

draw(renderer) [source]

Draw the Patch to the given renderer.

get_fontsize() [source]

Return the cell fontsize.

get_required_width(renderer) [source]

Get width required for this cell.

get_text() [source]

Return the cell Text instance.

get_text_bounds(renderer) [source]

Get text bounds in axes co-ordinates.

set_figure(fig) [source]

Set the Figure instance the artist belongs to.

Parameters:
fig : Figure
set_fontsize(size) [source]
set_text_props(**kwargs) [source]

update the text properties with kwargs

set_transform(trans) [source]

Set the artist transform.

Parameters:
t : Transform
class matplotlib.table.CustomCell(*args, visible_edges, **kwargs) [source]

Bases: matplotlib.table.Cell

A subclass of Cell where the sides may be visibly toggled.

get_path() [source]

Return a path where the edges specified by _visible_edges are drawn.

visible_edges
class matplotlib.table.Table(ax, loc=None, bbox=None, **kwargs) [source]

Bases: matplotlib.artist.Artist

Create a table of cells.

Table can have (optional) row and column headers.

Each entry in the table can be either text or patches.

Column widths and row heights for the table can be specified.

Return value is a sequence of text, line and patch instances that make up the table

AXESPAD = 0.02
FONTSIZE = 10
add_cell(row, col, *args, **kwargs) [source]

Add a cell to the table.

Parameters:
row : int

Row index.

col : int

Column index.

Returns:
`CustomCell`: Automatically created cell
auto_set_column_width(col) [source]

Given column indexs in either List, Tuple or int. Will be able to automatically set the columns into optimal sizes.

Here is the example of the input, which triger automatic adjustment on columns to optimal size by given index numbers. -1: the row labling 0: the 1st column 1: the 2nd column

Args:

col(List): list of indexs >>>table.auto_set_column_width([-1,0,1])

col(Tuple): tuple of indexs >>>table.auto_set_column_width((-1,0,1))

col(int): index integer >>>table.auto_set_column_width(-1) >>>table.auto_set_column_width(0) >>>table.auto_set_column_width(1)

auto_set_font_size(value=True) [source]

Automatically set font size.

codes = {'best': 0, 'bottom': 17, 'bottom left': 12, 'bottom right': 13, 'center': 9, 'center left': 5, 'center right': 6, 'left': 15, 'lower center': 7, 'lower left': 3, 'lower right': 4, 'right': 14, 'top': 16, 'top left': 11, 'top right': 10, 'upper center': 8, 'upper left': 2, 'upper right': 1}
contains(mouseevent) [source]

Test whether the mouse event occurred in the table.

Returns T/F, {}

draw(renderer) [source]

Derived classes drawing method

edges
get_celld() [source]

Return a dict of cells in the table.

get_child_artists()

Deprecated since version 3.0: The get_children function was deprecated in Matplotlib 3.0 and will be removed in 3.2.

Return the Artists contained by the table.

get_children() [source]

Return the Artists contained by the table.

get_window_extent(renderer) [source]

Return the bounding box of the table in window coords.

scale(xscale, yscale) [source]

Scale column widths by xscale and row heights by yscale.

set_fontsize(size) [source]

Set the font size, in points, of the cell text.

Parameters:
size : float
matplotlib.table.table(cellText=None, cellColours=None, cellLoc='right', colWidths=None, rowLabels=None, rowColours=None, rowLoc='left', colLabels=None, colColours=None, colLoc='center', loc='bottom', bbox=None, edges='closed') [source]

Factory function to generate a Table instance.

Thanks to John Gill for providing the class and table.

© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.0.0/api/table_api.html