| [ Web Proxy ] |
| Viewing: https://matplotlib.org/stable/api/_as_gen/../../gallery/animation/../ticks/../../api/table_api.html | [Back] [Original] |
matplotlib.table#Tables drawing.
Note
The table implementation in Matplotlib is lightly maintained. For a more featureful table implementation, you may wish to try blume.
Use the factory function table to create a ready-made
table from texts. If you need more control, use the Table class and its
methods.
The table consists of a grid of cells, which are indexed by (row, column). The cell (0, 0) is positioned at the top left.
Thanks to John Gill for providing the class and table.
Bases: Rectangle
A cell is a Rectangle with some associated Text.
As a user, you'll most likely not creates cells yourself. Instead, you
should use either the table factory function or
Table.add_cell.
The position of the bottom left corner of the cell.
The cell width.
The cell height.
The color of the cell border.
The cell facecolor.
Whether the cell background is filled.
The cell text.
The alignment of the text within the cell.
A dict defining the font properties of the text. Supported keys and
values are the keyword arguments accepted by FontProperties.
The cell edges to be drawn with a line: a substring of 'BRTL' (bottom, right, top, left), or one of 'open' (no edges drawn), 'closed' (all edges drawn), 'horizontal' (bottom and top), 'vertical' (right and left).
Padding between text and rectangle.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible
returns False).
RendererBase subclass.Notes
This method is overridden in the Artist subclasses.
Return a Path for the visible_edges.
Return the text bounds as (x, y, width, height) in table coordinates.
Set multiple properties at once.
a.set(a=A, b=B, c=C)
is equivalent to
a.set_a(A)
a.set_b(B)
a.set_c(C)
In addition to the full property names, aliases are also supported, e.g.
set(lw=2) is equivalent to set(linewidth=2), but it is an error
to pass both simultaneously.
The order of the individual setter calls matches the order of parameters
in set(). However, most properties do not depend on each other so
that order is rarely relevant.
Supported properties are
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
unknown
bool
antialiasedoraabool or None
(left, bottom, width, height)
CapStyleor {'butt', 'projecting', 'round'}
BboxBaseor Nonebool
Patch or (Path, Transform) or None
color or None
color or None
color or None
unknown
bool
unknown
str
{'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'}
unknown
color or 'edge' or None
unknown
bool
JoinStyleor {'miter', 'round', 'bevel'}object
{'-', '--', '-.', ':', '', ...} or (offset, on-off-seq)
float or None
bool
list of
AbstractPathEffectNone or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
unknown
unknown
str
bool
unknown
unknown
(float, float)
unknown
float
Set the Figure or SubFigure instance the artist belongs to.
Warning
This function should typically not be called by users.
This is a low-level API and only modifies the internal state of the Artist. Only modifying this is not enough and will typically lead to an inconsistent state, because the state of the figure has to be changed as well.
Users should typically instead call one of the high-level APIs, i.e.
Figure.add_artist or one of the Axes methods
Adding artists.
Update the text properties.
Valid keyword arguments are:
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
bool
bool
dict with properties for
FancyBboxPatchor Noneunknown
unknown
unknown
fontfamilyorfamilyorfontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'}
list of str, or tuple of str, or None
float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'}
{'normal', 'italic', 'oblique'}
{'normal', 'small-caps'}
fontweightorweight{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'}
str
{'left', 'center', 'right'}
bool
object
str or None
'normal' or float, default: 'normal'
str
bool
multialignmentorma{'left', 'right', 'center'}
bool
list of
AbstractPathEffectNone or bool or float or callable
(float, float)
bool
float or {'vertical', 'horizontal'}
{None, 'default', 'anchor', 'xtick', 'ytick'}
(scale: float, length: float, randomness: float)
bool or None
object
bool
str
bool, default:
rcParams["text.usetex"](default:False){'baseline', 'bottom', 'center', 'center_baseline', 'top'}
bool
bool
float
float
float
The cell edges to be drawn with a line.
Reading this property returns a substring of 'BRTL' (bottom, right, top, left').
When setting this property, you can use a substring of 'BRTL' or one of {'open', 'closed', 'horizontal', 'vertical'}.
Bases: Artist
A table of cells.
Note
table() has some fundamental design limitations and will not be
developed further. If you need more functionality, consider
blume.
The table consists of a grid of cells, which are indexed by (row, column).
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.
Note: You'll usually not create an empty table from scratch. Instead use
table to create a table from data.
Artist properties.
The border between the Axes and the table edge in Axes units.
Automatically set the widths of given columns to optimal sizes.
The indices of the columns to auto-scale.
Possible values where to place the table relative to the Axes.
Test whether the artist contains the mouse event.
MouseEventWhether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible
returns False).
RendererBase subclass.Notes
This method is overridden in the Artist subclasses.
The default value of visible_edges for newly added
cells using add_cell.
Notes
This setting does currently only affect newly created cells using
add_cell.
To change existing cells, you have to set their edges explicitly:
for c in tab.get_celld().values():
c.visible_edges = 'horizontal'
Return a dict of cells in the table mapping (row, column) to
Cells.
Notes
You can also directly index into the Table object to access individual cells:
cell = table[row, col]
Get the artist's bounding box in display space, ignoring clipping.
The bounding box's width and height are non-negative.
Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpected behavior in various cases such as interactive figures being resized or moved to a screen with different dpi, or figures that look fine on screen render incorrectly when saved to file.
To get accurate results you may need to manually call
savefig or draw_without_rendering to have
Matplotlib compute the rendered size.
RendererBase, optionalRenderer used to draw the figure (i.e. fig.canvas.get_renderer()).
See also
Artist.get_tightbboxGet the artist bounding box, taking clipping into account.
Set multiple properties at once.
a.set(a=A, b=B, c=C)
is equivalent to
a.set_a(A)
a.set_b(B)
a.set_c(C)
In addition to the full property names, aliases are also supported, e.g.
set(lw=2) is equivalent to set(linewidth=2), but it is an error
to pass both simultaneously.
The order of the individual setter calls matches the order of parameters
in set(). However, most properties do not depend on each other so
that order is rarely relevant.
Supported properties are
Property
Description
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
bool
BboxBaseor Nonebool
Patch or (Path, Transform) or None
float
str
bool
object
bool
list of
AbstractPathEffectNone or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
Set the font size, in points, of the cell text.
Notes
As long as auto font size has not been disabled, the value will be clipped such that the text fits horizontally into the cell.
You can disable this behavior using auto_set_font_size.
>>> the_table.auto_set_font_size(False)
>>> the_table.set_fontsize(20)
However, there is no automatic scaling of the row height so that the text may exceed the cell boundary.
Add a table to an Axes.
Note
table() has some fundamental design limitations and will not be
developed further. If you need more functionality, consider
blume.
At least one of cellText or cellColours 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.
The table can optionally have row and column headers, which are configured using rowLabels, rowColours, rowLoc and colLabels, colColours, colLoc respectively.
For finer grained control over tables, use the Table class and add it to
the Axes with Axes.add_table.
The texts to place into the table cells.
Note: Line breaks in the strings are currently not accounted for and will result in the text exceeding the cell boundaries.
The background colors of the cells.
The alignment of the text within the cells.
The column widths in units of the axes. If not given, all columns will have a width of 1 / ncols.
The text of the row header cells.
The colors of the row header cells.
The text alignment of the row header cells.
The text of the column header cells.
The colors of the column header cells.
The text alignment of the column header cells.
The position of the cell with respect to ax. This must be one of
the codes.
Bbox or [xmin, ymin, width, height], optionalA bounding box to draw the table into. If this is not None, this overrides loc.
The cell edges to be drawn with a line. See also
visible_edges.
TableThe created table.
Table properties.
Property |
Description |
|---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image |
|
float or None |
|
bool |
|
|
|
bool |
|
Patch or (Path, Transform) or None |
|
float |
|
str |
|
bool |
|
object |
|
bool |
|
list of |
|
None or bool or float or callable |
|
bool |
|
(scale: float, length: float, randomness: float) |
|
bool or None |
|
str |
|
bool |
|
float |
| Web Proxy Viewer | New URL | Original Page |