doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
set_position(position)[source] Set the position of the spine. Spine position is specified by a 2 tuple of (position type, amount). The position types are: 'outward': place the spine out from the data area by the specified number of points. (Negative values place the spine inwards.) 'axes': place the spine at the specified Axes coordinate (0 to 1). 'data': place the spine at the specified data coordinate. Additionally, shorthand notations define a special positions: 'center' -> ('axes', 0.5) 'zero' -> ('data', 0.0)
matplotlib.spines_api#matplotlib.spines.Spine.set_position
classmatplotlib.spines.Spines(**kwargs)[source] Bases: collections.abc.MutableMapping The container of all Spines in an Axes. The interface is dict-like mapping names (e.g. 'left') to Spine objects. Additionally it implements some pandas.Series-like features like accessing elements by attribute: spines['top'].set_visible(False) spines.top.set_visible(False) Multiple spines can be addressed simultaneously by passing a list: spines[['top', 'right']].set_visible(False) Use an open slice to address all spines: spines[:].set_visible(False) The latter two indexing methods will return a SpinesProxy that broadcasts all set_* calls to its members, but cannot be used for any other operation. classmethodfrom_dict(d)[source]
matplotlib.spines_api#matplotlib.spines.Spines
classmethodfrom_dict(d)[source]
matplotlib.spines_api#matplotlib.spines.Spines.from_dict
classmatplotlib.spines.SpinesProxy(spine_dict)[source] Bases: object A proxy to broadcast set_* method calls to all contained Spines. The proxy cannot be used for any other operations on its members. The supported methods are determined dynamically based on the contained spines. If not all spines support a given method, it's executed only on the subset of spines that support it.
matplotlib.spines_api#matplotlib.spines.SpinesProxy
matplotlib.style Styles are predefined sets of rcParams that define the visual appearance of a plot. Customizing Matplotlib with style sheets and rcParams describes the mechanism and usage of styles. The Style sheets reference gives an overview of the builtin styles. matplotlib.style.context(style, after_reset=False) Context manager for using style settings temporarily. Parameters stylestr, dict, Path or list A style specification. Valid options are: str The name of a style or a path/URL to a style file. For a list of available style names, see style.available. dict Dictionary with valid key/value pairs for matplotlib.rcParams. Path A path-like object which is a path to a style file. list A list of style specifiers (str, Path or dict) applied from first to last in the list. after_resetbool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings. matplotlib.style.reload_library()[source] Reload the style library. matplotlib.style.use(style)[source] Use Matplotlib style settings from a style specification. The style name of 'default' is reserved for reverting back to the default style settings. Note This updates the rcParams with the settings from the style. rcParams not defined in the style are kept. Parameters stylestr, dict, Path or list A style specification. Valid options are: str The name of a style or a path/URL to a style file. For a list of available style names, see style.available. dict Dictionary with valid key/value pairs for matplotlib.rcParams. Path A path-like object which is a path to a style file. list A list of style specifiers (str, Path or dict) applied from first to last in the list. Notes The following rcParams are not related to style and will be ignored if found in a style specification: backend backend_fallback datapath date.epoch docstring.hardcopy figure.max_open_warning figure.raise_window interactive savefig.directory timezone tk.window_focus toolbar webagg.address webagg.open_in_browser webagg.port webagg.port_retries matplotlib.style.library A dict mapping from style name to RcParams defining that style. This is meant to be read-only. Use reload_library to update. matplotlib.style.available List of the names of the available styles. This is meant to be read-only. Use reload_library to update.
matplotlib.style_api
matplotlib.style.context(style, after_reset=False) Context manager for using style settings temporarily. Parameters stylestr, dict, Path or list A style specification. Valid options are: str The name of a style or a path/URL to a style file. For a list of available style names, see style.available. dict Dictionary with valid key/value pairs for matplotlib.rcParams. Path A path-like object which is a path to a style file. list A list of style specifiers (str, Path or dict) applied from first to last in the list. after_resetbool If True, apply style after resetting settings to their defaults; otherwise, apply style on top of the current settings.
matplotlib.style_api#matplotlib.style.context
matplotlib.style.reload_library()[source] Reload the style library.
matplotlib.style_api#matplotlib.style.reload_library
matplotlib.style.available List of the names of the available styles. This is meant to be read-only. Use reload_library to update.
matplotlib.style_api#matplotlib.style.matplotlib.style.available
matplotlib.style.library A dict mapping from style name to RcParams defining that style. This is meant to be read-only. Use reload_library to update.
matplotlib.style_api#matplotlib.style.matplotlib.style.library
matplotlib.style.use(style)[source] Use Matplotlib style settings from a style specification. The style name of 'default' is reserved for reverting back to the default style settings. Note This updates the rcParams with the settings from the style. rcParams not defined in the style are kept. Parameters stylestr, dict, Path or list A style specification. Valid options are: str The name of a style or a path/URL to a style file. For a list of available style names, see style.available. dict Dictionary with valid key/value pairs for matplotlib.rcParams. Path A path-like object which is a path to a style file. list A list of style specifiers (str, Path or dict) applied from first to last in the list. Notes The following rcParams are not related to style and will be ignored if found in a style specification: backend backend_fallback datapath date.epoch docstring.hardcopy figure.max_open_warning figure.raise_window interactive savefig.directory timezone tk.window_focus toolbar webagg.address webagg.open_in_browser webagg.port webagg.port_retries
matplotlib.style_api#matplotlib.style.use
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. classmatplotlib.table.Cell(xy, width, height, edgecolor='k', facecolor='w', fill=True, text='', loc=None, fontproperties=None, *, visible_edges='closed')[source] Bases: matplotlib.patches.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. Parameters xy2-tuple The position of the bottom left corner of the cell. widthfloat The cell width. heightfloat The cell height. edgecolorcolor The color of the cell border. facecolorcolor The cell facecolor. fillbool Whether the cell background is filled. textstr The cell text. loc{'left', 'center', 'right'}, default: 'right' The alignment of the text within the cell. fontpropertiesdict A dict defining the font properties of the text. Supported keys and values are the keyword arguments accepted by FontProperties. visible_edgesstr, default: 'closed' 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). PAD=0.1 Padding between text and rectangle. auto_set_font_size(renderer)[source] Shrink font size until the text fits into the cell width. draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. get_fontsize()[source] Return the cell fontsize. get_path()[source] Return a Path for the visible_edges. get_required_width(renderer)[source] Return the minimal required width for the cell. get_text()[source] Return the cell Text instance. get_text_bounds(renderer)[source] Return the text bounds as (x, y, width, height) in table coordinates. set(*, agg_filter=<UNSET>, alpha=<UNSET>, angle=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, bounds=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, fontsize=<UNSET>, gid=<UNSET>, hatch=<UNSET>, height=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text_props=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, x=<UNSET>, xy=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None angle unknown animated bool antialiased or aa bool or None bounds (left, bottom, width, height) capstyle CapStyle or {'butt', 'projecting', 'round'} clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None color color edgecolor or ec color or None facecolor or fc color or None figure unknown fill bool fontsize unknown gid str hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} height unknown in_layout bool joinstyle JoinStyle or {'miter', 'round', 'bevel'} label object linestyle or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} linewidth or lw float or None path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None text_props unknown transform unknown url str visible bool width unknown x unknown xy (float, float) y unknown zorder float set_figure(fig)[source] Set the Figure instance the artist belongs to. Parameters figFigure set_fontsize(size)[source] Set the text fontsize. set_text_props(**kwargs)[source] Update the text properties. Valid keyword arguments are: Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color or c color figure Figure fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float set_transform(trans)[source] Set the artist transform. Parameters tTransform propertyvisible_edges 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'}. matplotlib.table.CustomCell[source] alias of matplotlib.table.Cell classmatplotlib.table.Table(ax, loc=None, bbox=None, **kwargs)[source] Bases: matplotlib.artist.Artist A table of cells. 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. Parameters axmatplotlib.axes.Axes The Axes to plot the table into. locstr The position of the cell with respect to ax. This must be one of the codes. bboxBbox or None A bounding box to draw the table into. If this is not None, this overrides loc. Other Parameters **kwargs Artist properties. AXESPAD=0.02 The border between the Axes and the table edge in Axes units. FONTSIZE=10 add_cell(row, col, *args, **kwargs)[source] Create a cell and add it to the table. Parameters rowint Row index. colint Column index. *args, **kwargs All other parameters are passed on to Cell. Returns Cell The created cell. auto_set_column_width(col)[source] Automatically set the widths of given columns to optimal sizes. Parameters colint or sequence of ints The indices of the columns to auto-scale. 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} Possible values where to place the table relative to the Axes. contains(mouseevent)[source] Test whether the artist contains the mouse event. Parameters mouseeventmatplotlib.backend_bases.MouseEvent Returns containsbool Whether any values are within the radius. detailsdict 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(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. propertyedges 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' get_celld()[source] 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_children()[source] Return the Artists contained by the table. get_window_extent(renderer)[source] Get the artist's bounding box in display space. The bounding box' width and height are nonnegative. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0. Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly. scale(xscale, yscale)[source] Scale column widths by xscale and row heights by yscale. set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, fontsize=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None figure Figure fontsize float gid str in_layout bool label object path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None transform Transform url str visible bool zorder float set_fontsize(size)[source] Set the font size, in points, of the cell text. Parameters sizefloat 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. matplotlib.table.table(ax, 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', **kwargs)[source] Add a table to an Axes. 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. Parameters cellText2D list of str, optional 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. cellColours2D list of colors, optional The background colors of the cells. cellLoc{'left', 'center', 'right'}, default: 'right' The alignment of the text within the cells. colWidthslist of float, optional The column widths in units of the axes. If not given, all columns will have a width of 1 / ncols. rowLabelslist of str, optional The text of the row header cells. rowColourslist of colors, optional The colors of the row header cells. rowLoc{'left', 'center', 'right'}, default: 'left' The text alignment of the row header cells. colLabelslist of str, optional The text of the column header cells. colColourslist of colors, optional The colors of the column header cells. colLoc{'left', 'center', 'right'}, default: 'left' The text alignment of the column header cells. locstr, optional The position of the cell with respect to ax. This must be one of the codes. bboxBbox, optional A bounding box to draw the table into. If this is not None, this overrides loc. edgessubstring of 'BRTL' or {'open', 'closed', 'horizontal', 'vertical'} The cell edges to be drawn with a line. See also visible_edges. Returns Table The created table. Other Parameters **kwargs Table properties. Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None figure Figure fontsize float gid str in_layout bool label object path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None transform Transform url str visible bool zorder float
matplotlib.table_api
classmatplotlib.table.Cell(xy, width, height, edgecolor='k', facecolor='w', fill=True, text='', loc=None, fontproperties=None, *, visible_edges='closed')[source] Bases: matplotlib.patches.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. Parameters xy2-tuple The position of the bottom left corner of the cell. widthfloat The cell width. heightfloat The cell height. edgecolorcolor The color of the cell border. facecolorcolor The cell facecolor. fillbool Whether the cell background is filled. textstr The cell text. loc{'left', 'center', 'right'}, default: 'right' The alignment of the text within the cell. fontpropertiesdict A dict defining the font properties of the text. Supported keys and values are the keyword arguments accepted by FontProperties. visible_edgesstr, default: 'closed' 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). PAD=0.1 Padding between text and rectangle. auto_set_font_size(renderer)[source] Shrink font size until the text fits into the cell width. draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. get_fontsize()[source] Return the cell fontsize. get_path()[source] Return a Path for the visible_edges. get_required_width(renderer)[source] Return the minimal required width for the cell. get_text()[source] Return the cell Text instance. get_text_bounds(renderer)[source] Return the text bounds as (x, y, width, height) in table coordinates. set(*, agg_filter=<UNSET>, alpha=<UNSET>, angle=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, bounds=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, fontsize=<UNSET>, gid=<UNSET>, hatch=<UNSET>, height=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text_props=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, x=<UNSET>, xy=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None angle unknown animated bool antialiased or aa bool or None bounds (left, bottom, width, height) capstyle CapStyle or {'butt', 'projecting', 'round'} clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None color color edgecolor or ec color or None facecolor or fc color or None figure unknown fill bool fontsize unknown gid str hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} height unknown in_layout bool joinstyle JoinStyle or {'miter', 'round', 'bevel'} label object linestyle or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} linewidth or lw float or None path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None text_props unknown transform unknown url str visible bool width unknown x unknown xy (float, float) y unknown zorder float set_figure(fig)[source] Set the Figure instance the artist belongs to. Parameters figFigure set_fontsize(size)[source] Set the text fontsize. set_text_props(**kwargs)[source] Update the text properties. Valid keyword arguments are: Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color or c color figure Figure fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float set_transform(trans)[source] Set the artist transform. Parameters tTransform propertyvisible_edges 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'}.
matplotlib.table_api#matplotlib.table.Cell
auto_set_font_size(renderer)[source] Shrink font size until the text fits into the cell width.
matplotlib.table_api#matplotlib.table.Cell.auto_set_font_size
draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses.
matplotlib.table_api#matplotlib.table.Cell.draw
get_fontsize()[source] Return the cell fontsize.
matplotlib.table_api#matplotlib.table.Cell.get_fontsize
get_path()[source] Return a Path for the visible_edges.
matplotlib.table_api#matplotlib.table.Cell.get_path
get_required_width(renderer)[source] Return the minimal required width for the cell.
matplotlib.table_api#matplotlib.table.Cell.get_required_width
get_text()[source] Return the cell Text instance.
matplotlib.table_api#matplotlib.table.Cell.get_text
get_text_bounds(renderer)[source] Return the text bounds as (x, y, width, height) in table coordinates.
matplotlib.table_api#matplotlib.table.Cell.get_text_bounds
PAD=0.1 Padding between text and rectangle.
matplotlib.table_api#matplotlib.table.Cell.PAD
set(*, agg_filter=<UNSET>, alpha=<UNSET>, angle=<UNSET>, animated=<UNSET>, antialiased=<UNSET>, bounds=<UNSET>, capstyle=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, edgecolor=<UNSET>, facecolor=<UNSET>, fill=<UNSET>, fontsize=<UNSET>, gid=<UNSET>, hatch=<UNSET>, height=<UNSET>, in_layout=<UNSET>, joinstyle=<UNSET>, label=<UNSET>, linestyle=<UNSET>, linewidth=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text_props=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, width=<UNSET>, x=<UNSET>, xy=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None angle unknown animated bool antialiased or aa bool or None bounds (left, bottom, width, height) capstyle CapStyle or {'butt', 'projecting', 'round'} clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None color color edgecolor or ec color or None facecolor or fc color or None figure unknown fill bool fontsize unknown gid str hatch {'/', '\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} height unknown in_layout bool joinstyle JoinStyle or {'miter', 'round', 'bevel'} label object linestyle or ls {'-', '--', '-.', ':', '', (offset, on-off-seq), ...} linewidth or lw float or None path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None text_props unknown transform unknown url str visible bool width unknown x unknown xy (float, float) y unknown zorder float
matplotlib.table_api#matplotlib.table.Cell.set
set_figure(fig)[source] Set the Figure instance the artist belongs to. Parameters figFigure
matplotlib.table_api#matplotlib.table.Cell.set_figure
set_fontsize(size)[source] Set the text fontsize.
matplotlib.table_api#matplotlib.table.Cell.set_fontsize
set_text_props(**kwargs)[source] Update the text properties. Valid keyword arguments are: Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color or c color figure Figure fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float
matplotlib.table_api#matplotlib.table.Cell.set_text_props
set_transform(trans)[source] Set the artist transform. Parameters tTransform
matplotlib.table_api#matplotlib.table.Cell.set_transform
matplotlib.table.CustomCell[source] alias of matplotlib.table.Cell
matplotlib.table_api#matplotlib.table.CustomCell
classmatplotlib.table.Table(ax, loc=None, bbox=None, **kwargs)[source] Bases: matplotlib.artist.Artist A table of cells. 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. Parameters axmatplotlib.axes.Axes The Axes to plot the table into. locstr The position of the cell with respect to ax. This must be one of the codes. bboxBbox or None A bounding box to draw the table into. If this is not None, this overrides loc. Other Parameters **kwargs Artist properties. AXESPAD=0.02 The border between the Axes and the table edge in Axes units. FONTSIZE=10 add_cell(row, col, *args, **kwargs)[source] Create a cell and add it to the table. Parameters rowint Row index. colint Column index. *args, **kwargs All other parameters are passed on to Cell. Returns Cell The created cell. auto_set_column_width(col)[source] Automatically set the widths of given columns to optimal sizes. Parameters colint or sequence of ints The indices of the columns to auto-scale. 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} Possible values where to place the table relative to the Axes. contains(mouseevent)[source] Test whether the artist contains the mouse event. Parameters mouseeventmatplotlib.backend_bases.MouseEvent Returns containsbool Whether any values are within the radius. detailsdict 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(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. propertyedges 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' get_celld()[source] 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_children()[source] Return the Artists contained by the table. get_window_extent(renderer)[source] Get the artist's bounding box in display space. The bounding box' width and height are nonnegative. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0. Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly. scale(xscale, yscale)[source] Scale column widths by xscale and row heights by yscale. set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, fontsize=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None figure Figure fontsize float gid str in_layout bool label object path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None transform Transform url str visible bool zorder float set_fontsize(size)[source] Set the font size, in points, of the cell text. Parameters sizefloat 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.
matplotlib.table_api#matplotlib.table.Table
matplotlib.table.table(ax, 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', **kwargs)[source] Add a table to an Axes. 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. Parameters cellText2D list of str, optional 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. cellColours2D list of colors, optional The background colors of the cells. cellLoc{'left', 'center', 'right'}, default: 'right' The alignment of the text within the cells. colWidthslist of float, optional The column widths in units of the axes. If not given, all columns will have a width of 1 / ncols. rowLabelslist of str, optional The text of the row header cells. rowColourslist of colors, optional The colors of the row header cells. rowLoc{'left', 'center', 'right'}, default: 'left' The text alignment of the row header cells. colLabelslist of str, optional The text of the column header cells. colColourslist of colors, optional The colors of the column header cells. colLoc{'left', 'center', 'right'}, default: 'left' The text alignment of the column header cells. locstr, optional The position of the cell with respect to ax. This must be one of the codes. bboxBbox, optional A bounding box to draw the table into. If this is not None, this overrides loc. edgessubstring of 'BRTL' or {'open', 'closed', 'horizontal', 'vertical'} The cell edges to be drawn with a line. See also visible_edges. Returns Table The created table. Other Parameters **kwargs Table properties. Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None figure Figure fontsize float gid str in_layout bool label object path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None transform Transform url str visible bool zorder float
matplotlib.table_api#matplotlib.table.table
add_cell(row, col, *args, **kwargs)[source] Create a cell and add it to the table. Parameters rowint Row index. colint Column index. *args, **kwargs All other parameters are passed on to Cell. Returns Cell The created cell.
matplotlib.table_api#matplotlib.table.Table.add_cell
auto_set_column_width(col)[source] Automatically set the widths of given columns to optimal sizes. Parameters colint or sequence of ints The indices of the columns to auto-scale.
matplotlib.table_api#matplotlib.table.Table.auto_set_column_width
auto_set_font_size(value=True)[source] Automatically set font size.
matplotlib.table_api#matplotlib.table.Table.auto_set_font_size
AXESPAD=0.02 The border between the Axes and the table edge in Axes units.
matplotlib.table_api#matplotlib.table.Table.AXESPAD
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} Possible values where to place the table relative to the Axes.
matplotlib.table_api#matplotlib.table.Table.codes
contains(mouseevent)[source] Test whether the artist contains the mouse event. Parameters mouseeventmatplotlib.backend_bases.MouseEvent Returns containsbool Whether any values are within the radius. detailsdict 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.
matplotlib.table_api#matplotlib.table.Table.contains
draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses.
matplotlib.table_api#matplotlib.table.Table.draw
FONTSIZE=10
matplotlib.table_api#matplotlib.table.Table.FONTSIZE
get_celld()[source] 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]
matplotlib.table_api#matplotlib.table.Table.get_celld
get_children()[source] Return the Artists contained by the table.
matplotlib.table_api#matplotlib.table.Table.get_children
get_window_extent(renderer)[source] Get the artist's bounding box in display space. The bounding box' width and height are nonnegative. Subclasses should override for inclusion in the bounding box "tight" calculation. Default is to return an empty bounding box at 0, 0. Be careful when using this function, the results will not update if the artist window extent of the artist changes. The extent can change due to any changes in the transform stack, such as changing the axes limits, the figure size, or the canvas used (as is done when saving a figure). This can lead to unexpected behavior where interactive figures will look fine on the screen, but will save incorrectly.
matplotlib.table_api#matplotlib.table.Table.get_window_extent
scale(xscale, yscale)[source] Scale column widths by xscale and row heights by yscale.
matplotlib.table_api#matplotlib.table.Table.scale
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, fontsize=<UNSET>, gid=<UNSET>, in_layout=<UNSET>, label=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, rasterized=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, transform=<UNSET>, url=<UNSET>, visible=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None figure Figure fontsize float gid str in_layout bool label object path_effects AbstractPathEffect picker None or bool or float or callable rasterized bool sketch_params (scale: float, length: float, randomness: float) snap bool or None transform Transform url str visible bool zorder float
matplotlib.table_api#matplotlib.table.Table.set
set_fontsize(size)[source] Set the font size, in points, of the cell text. Parameters sizefloat 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.
matplotlib.table_api#matplotlib.table.Table.set_fontsize
matplotlib.test(verbosity=None, coverage=False, **kwargs)[source] [Deprecated] Run the matplotlib test suite. Notes Deprecated since version 3.5.
matplotlib.testing_api#matplotlib.test
matplotlib.testing matplotlib.test() matplotlib.test(verbosity=None, coverage=False, **kwargs)[source] [Deprecated] Run the matplotlib test suite. Notes Deprecated since version 3.5. matplotlib.testing Helper functions for testing. matplotlib.testing.set_font_settings_for_testing()[source] matplotlib.testing.set_reproducibility_for_testing()[source] matplotlib.testing.setup()[source] matplotlib.testing.compare Utilities for comparing image results. matplotlib.testing.compare.calculate_rms(expected_image, actual_image)[source] Calculate the per-pixel errors, then compute the root mean square error. matplotlib.testing.compare.comparable_formats()[source] Return the list of file formats that compare_images can compare on this system. Returns list of str E.g. ['png', 'pdf', 'svg', 'eps']. matplotlib.testing.compare.compare_images(expected, actual, tol, in_decorator=False)[source] Compare two "image" files checking differences within a tolerance. The two given filenames may point to files which are convertible to PNG via the converter dictionary. The underlying RMS is calculated with the calculate_rms function. Parameters expectedstr The filename of the expected image. actualstr The filename of the actual image. tolfloat The tolerance (a color value difference, where 255 is the maximal difference). The test fails if the average pixel difference is greater than this value. in_decoratorbool Determines the output format. If called from image_comparison decorator, this should be True. (default=False) Returns None or dict or str Return None if the images are equal within the given tolerance. If the images differ, the return value depends on in_decorator. If in_decorator is true, a dict with the following entries is returned: rms: The RMS of the image difference. expected: The filename of the expected image. actual: The filename of the actual image. diff_image: The filename of the difference image. tol: The comparison tolerance. Otherwise, a human-readable multi-line string representation of this information is returned. Examples img1 = "./baseline/plot.png" img2 = "./output/plot.png" compare_images(img1, img2, 0.001) matplotlib.testing.decorators classmatplotlib.testing.decorators.CleanupTestCase(methodName='runTest')[source] Bases: unittest.case.TestCase A wrapper for unittest.TestCase that includes cleanup operations. Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. classmethodsetUpClass()[source] Hook method for setting up class fixture before running tests in the class. classmethodtearDownClass()[source] Hook method for deconstructing the class fixture after running all tests in the class. matplotlib.testing.decorators.check_figures_equal(*, extensions=('png', 'pdf', 'svg'), tol=0)[source] Decorator for test cases that generate and compare two figures. The decorated function must take two keyword arguments, fig_test and fig_ref, and draw the test and reference images on them. After the function returns, the figures are saved and compared. This decorator should be preferred over image_comparison when possible in order to keep the size of the test suite from ballooning. Parameters extensionslist, default: ["png", "pdf", "svg"] The extensions to test. tolfloat The RMS threshold above which the test is considered failed. Raises RuntimeError If any new figures are created (and not subsequently closed) inside the test function. Examples Check that calling Axes.plot with a single argument plots it against [0, 1, 2, ...]: @check_figures_equal() def test_plot(fig_test, fig_ref): fig_test.subplots().plot([1, 3, 5]) fig_ref.subplots().plot([0, 1, 2], [1, 3, 5]) matplotlib.testing.decorators.check_freetype_version(ver)[source] matplotlib.testing.decorators.cleanup(style=None)[source] A decorator to ensure that any global state is reset before running a test. Parameters stylestr, dict, or list, optional The style(s) to apply. Defaults to ["classic", "_classic_test_patch"]. matplotlib.testing.decorators.image_comparison(baseline_images, extensions=None, tol=0, freetype_version=None, remove_text=False, savefig_kwarg=None, style=('classic', '_classic_test_patch'))[source] Compare images generated by the test with those specified in baseline_images, which must correspond, else an ImageComparisonFailure exception will be raised. Parameters baseline_imageslist or None A list of strings specifying the names of the images generated by calls to Figure.savefig. If None, the test function must use the baseline_images fixture, either as a parameter or with pytest.mark.usefixtures. This value is only allowed when using pytest. extensionsNone or list of str The list of extensions to test, e.g. ['png', 'pdf']. If None, defaults to all supported extensions: png, pdf, and svg. When testing a single extension, it can be directly included in the names passed to baseline_images. In that case, extensions must not be set. In order to keep the size of the test suite from ballooning, we only include the svg or pdf outputs if the test is explicitly exercising a feature dependent on that backend (see also the check_figures_equal decorator for that purpose). tolfloat, default: 0 The RMS threshold above which the test is considered failed. Due to expected small differences in floating-point calculations, on 32-bit systems an additional 0.06 is added to this threshold. freetype_versionstr or tuple The expected freetype version or range of versions for this test to pass. remove_textbool Remove the title and tick text from the figure before comparison. This is useful to make the baseline images independent of variations in text rendering between different versions of FreeType. This does not remove other, more deliberate, text, such as legends and annotations. savefig_kwargdict Optional arguments that are passed to the savefig method. stylestr, dict, or list The optional style(s) to apply to the image test. The test itself can also apply additional styles if desired. Defaults to ["classic", "_classic_test_patch"]. matplotlib.testing.decorators.remove_ticks_and_titles(figure)[source] matplotlib.testing.exceptions exceptionmatplotlib.testing.exceptions.ImageComparisonFailure[source] Bases: AssertionError Raise this exception to mark a test as a comparison between two images.
matplotlib.testing_api
matplotlib.testing.compare.calculate_rms(expected_image, actual_image)[source] Calculate the per-pixel errors, then compute the root mean square error.
matplotlib.testing_api#matplotlib.testing.compare.calculate_rms
matplotlib.testing.compare.comparable_formats()[source] Return the list of file formats that compare_images can compare on this system. Returns list of str E.g. ['png', 'pdf', 'svg', 'eps'].
matplotlib.testing_api#matplotlib.testing.compare.comparable_formats
matplotlib.testing.compare.compare_images(expected, actual, tol, in_decorator=False)[source] Compare two "image" files checking differences within a tolerance. The two given filenames may point to files which are convertible to PNG via the converter dictionary. The underlying RMS is calculated with the calculate_rms function. Parameters expectedstr The filename of the expected image. actualstr The filename of the actual image. tolfloat The tolerance (a color value difference, where 255 is the maximal difference). The test fails if the average pixel difference is greater than this value. in_decoratorbool Determines the output format. If called from image_comparison decorator, this should be True. (default=False) Returns None or dict or str Return None if the images are equal within the given tolerance. If the images differ, the return value depends on in_decorator. If in_decorator is true, a dict with the following entries is returned: rms: The RMS of the image difference. expected: The filename of the expected image. actual: The filename of the actual image. diff_image: The filename of the difference image. tol: The comparison tolerance. Otherwise, a human-readable multi-line string representation of this information is returned. Examples img1 = "./baseline/plot.png" img2 = "./output/plot.png" compare_images(img1, img2, 0.001)
matplotlib.testing_api#matplotlib.testing.compare.compare_images
matplotlib.testing.decorators.check_figures_equal(*, extensions=('png', 'pdf', 'svg'), tol=0)[source] Decorator for test cases that generate and compare two figures. The decorated function must take two keyword arguments, fig_test and fig_ref, and draw the test and reference images on them. After the function returns, the figures are saved and compared. This decorator should be preferred over image_comparison when possible in order to keep the size of the test suite from ballooning. Parameters extensionslist, default: ["png", "pdf", "svg"] The extensions to test. tolfloat The RMS threshold above which the test is considered failed. Raises RuntimeError If any new figures are created (and not subsequently closed) inside the test function. Examples Check that calling Axes.plot with a single argument plots it against [0, 1, 2, ...]: @check_figures_equal() def test_plot(fig_test, fig_ref): fig_test.subplots().plot([1, 3, 5]) fig_ref.subplots().plot([0, 1, 2], [1, 3, 5])
matplotlib.testing_api#matplotlib.testing.decorators.check_figures_equal
matplotlib.testing.decorators.check_freetype_version(ver)[source]
matplotlib.testing_api#matplotlib.testing.decorators.check_freetype_version
matplotlib.testing.decorators.cleanup(style=None)[source] A decorator to ensure that any global state is reset before running a test. Parameters stylestr, dict, or list, optional The style(s) to apply. Defaults to ["classic", "_classic_test_patch"].
matplotlib.testing_api#matplotlib.testing.decorators.cleanup
classmatplotlib.testing.decorators.CleanupTestCase(methodName='runTest')[source] Bases: unittest.case.TestCase A wrapper for unittest.TestCase that includes cleanup operations. Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name. classmethodsetUpClass()[source] Hook method for setting up class fixture before running tests in the class. classmethodtearDownClass()[source] Hook method for deconstructing the class fixture after running all tests in the class.
matplotlib.testing_api#matplotlib.testing.decorators.CleanupTestCase
classmethodsetUpClass()[source] Hook method for setting up class fixture before running tests in the class.
matplotlib.testing_api#matplotlib.testing.decorators.CleanupTestCase.setUpClass
classmethodtearDownClass()[source] Hook method for deconstructing the class fixture after running all tests in the class.
matplotlib.testing_api#matplotlib.testing.decorators.CleanupTestCase.tearDownClass
matplotlib.testing.decorators.image_comparison(baseline_images, extensions=None, tol=0, freetype_version=None, remove_text=False, savefig_kwarg=None, style=('classic', '_classic_test_patch'))[source] Compare images generated by the test with those specified in baseline_images, which must correspond, else an ImageComparisonFailure exception will be raised. Parameters baseline_imageslist or None A list of strings specifying the names of the images generated by calls to Figure.savefig. If None, the test function must use the baseline_images fixture, either as a parameter or with pytest.mark.usefixtures. This value is only allowed when using pytest. extensionsNone or list of str The list of extensions to test, e.g. ['png', 'pdf']. If None, defaults to all supported extensions: png, pdf, and svg. When testing a single extension, it can be directly included in the names passed to baseline_images. In that case, extensions must not be set. In order to keep the size of the test suite from ballooning, we only include the svg or pdf outputs if the test is explicitly exercising a feature dependent on that backend (see also the check_figures_equal decorator for that purpose). tolfloat, default: 0 The RMS threshold above which the test is considered failed. Due to expected small differences in floating-point calculations, on 32-bit systems an additional 0.06 is added to this threshold. freetype_versionstr or tuple The expected freetype version or range of versions for this test to pass. remove_textbool Remove the title and tick text from the figure before comparison. This is useful to make the baseline images independent of variations in text rendering between different versions of FreeType. This does not remove other, more deliberate, text, such as legends and annotations. savefig_kwargdict Optional arguments that are passed to the savefig method. stylestr, dict, or list The optional style(s) to apply to the image test. The test itself can also apply additional styles if desired. Defaults to ["classic", "_classic_test_patch"].
matplotlib.testing_api#matplotlib.testing.decorators.image_comparison
matplotlib.testing.decorators.remove_ticks_and_titles(figure)[source]
matplotlib.testing_api#matplotlib.testing.decorators.remove_ticks_and_titles
exceptionmatplotlib.testing.exceptions.ImageComparisonFailure[source] Bases: AssertionError Raise this exception to mark a test as a comparison between two images.
matplotlib.testing_api#matplotlib.testing.exceptions.ImageComparisonFailure
matplotlib.testing.set_font_settings_for_testing()[source]
matplotlib.testing_api#matplotlib.testing.set_font_settings_for_testing
matplotlib.testing.set_reproducibility_for_testing()[source]
matplotlib.testing_api#matplotlib.testing.set_reproducibility_for_testing
matplotlib.testing.setup()[source]
matplotlib.testing_api#matplotlib.testing.setup
matplotlib.texmanager Support for embedded TeX expressions in Matplotlib. Requirements: LaTeX. *Agg backends: dvipng>=1.6. PS backend: PSfrag, dvips, and Ghostscript>=9.0. PDF and SVG backends: if LuaTeX is present, it will be used to speed up some post-processing steps, but note that it is not used to parse the TeX string itself (only LaTeX is supported). To enable TeX rendering of all text in your Matplotlib figure, set rcParams["text.usetex"] (default: False) to True. TeX and dvipng/dvips processing results are cached in ~/.matplotlib/tex.cache for reuse between sessions. TexManager.get_rgba can also be used to directly obtain raster output as RGBA NumPy arrays. classmatplotlib.texmanager.TexManager[source] Bases: object Convert strings to dvi files using TeX, caching the results to a directory. Repeated calls to this constructor always return the same instance. propertyfont_families[source] propertyfont_family[source] propertyfont_info[source] get_basefile(tex, fontsize, dpi=None)[source] Return a filename based on a hash of the string, fontsize, and dpi. get_custom_preamble()[source] Return a string containing user additions to the tex preamble. get_font_config()[source] get_font_preamble()[source] Return a string containing font configuration for the tex preamble. get_grey(tex, fontsize=None, dpi=None)[source] Return the alpha channel. get_rgba(tex, fontsize=None, dpi=None, rgb=(0, 0, 0))[source] Return latex's rendering of the tex string as an rgba array. Examples >>> texmanager = TexManager() >>> s = r"\TeX\ is $\displaystyle\sum_n\frac{-e^{i\pi}}{2^n}$!" >>> Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1, 0, 0)) get_text_width_height_descent(tex, fontsize, renderer=None)[source] Return width, height and descent of the text. propertygrey_arrayd[source] make_dvi(tex, fontsize)[source] Generate a dvi file containing latex's layout of tex string. Return the file name. make_png(tex, fontsize, dpi)[source] Generate a png file containing latex's rendering of tex string. Return the file name. make_tex(tex, fontsize)[source] Generate a tex file to render the tex string at a specific font size. Return the file name. texcache='/home/elliott/.cache/matplotlib/tex.cache'
matplotlib.texmanager_api
classmatplotlib.texmanager.TexManager[source] Bases: object Convert strings to dvi files using TeX, caching the results to a directory. Repeated calls to this constructor always return the same instance. propertyfont_families[source] propertyfont_family[source] propertyfont_info[source] get_basefile(tex, fontsize, dpi=None)[source] Return a filename based on a hash of the string, fontsize, and dpi. get_custom_preamble()[source] Return a string containing user additions to the tex preamble. get_font_config()[source] get_font_preamble()[source] Return a string containing font configuration for the tex preamble. get_grey(tex, fontsize=None, dpi=None)[source] Return the alpha channel. get_rgba(tex, fontsize=None, dpi=None, rgb=(0, 0, 0))[source] Return latex's rendering of the tex string as an rgba array. Examples >>> texmanager = TexManager() >>> s = r"\TeX\ is $\displaystyle\sum_n\frac{-e^{i\pi}}{2^n}$!" >>> Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1, 0, 0)) get_text_width_height_descent(tex, fontsize, renderer=None)[source] Return width, height and descent of the text. propertygrey_arrayd[source] make_dvi(tex, fontsize)[source] Generate a dvi file containing latex's layout of tex string. Return the file name. make_png(tex, fontsize, dpi)[source] Generate a png file containing latex's rendering of tex string. Return the file name. make_tex(tex, fontsize)[source] Generate a tex file to render the tex string at a specific font size. Return the file name. texcache='/home/elliott/.cache/matplotlib/tex.cache'
matplotlib.texmanager_api#matplotlib.texmanager.TexManager
get_basefile(tex, fontsize, dpi=None)[source] Return a filename based on a hash of the string, fontsize, and dpi.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_basefile
get_custom_preamble()[source] Return a string containing user additions to the tex preamble.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_custom_preamble
get_font_config()[source]
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_font_config
get_font_preamble()[source] Return a string containing font configuration for the tex preamble.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_font_preamble
get_grey(tex, fontsize=None, dpi=None)[source] Return the alpha channel.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_grey
get_rgba(tex, fontsize=None, dpi=None, rgb=(0, 0, 0))[source] Return latex's rendering of the tex string as an rgba array. Examples >>> texmanager = TexManager() >>> s = r"\TeX\ is $\displaystyle\sum_n\frac{-e^{i\pi}}{2^n}$!" >>> Z = texmanager.get_rgba(s, fontsize=12, dpi=80, rgb=(1, 0, 0))
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_rgba
get_text_width_height_descent(tex, fontsize, renderer=None)[source] Return width, height and descent of the text.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.get_text_width_height_descent
make_dvi(tex, fontsize)[source] Generate a dvi file containing latex's layout of tex string. Return the file name.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.make_dvi
make_png(tex, fontsize, dpi)[source] Generate a png file containing latex's rendering of tex string. Return the file name.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.make_png
make_tex(tex, fontsize)[source] Generate a tex file to render the tex string at a specific font size. Return the file name.
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.make_tex
texcache='/home/elliott/.cache/matplotlib/tex.cache'
matplotlib.texmanager_api#matplotlib.texmanager.TexManager.texcache
matplotlib.text Classes for including text in a figure. classmatplotlib.text.Annotation(text, xy, xytext=None, xycoords='data', textcoords=None, arrowprops=None, annotation_clip=None, **kwargs)[source] Bases: matplotlib.text.Text, matplotlib.text._AnnotationBase An Annotation is a Text that can refer to a specific position xy. Optionally an arrow pointing from the text to xy can be drawn. Attributes xy The annotated position. xycoords The coordinate system for xy. arrow_patch A FancyArrowPatch to point from xytext to xy. Annotate the point xy with text text. In the simplest form, the text is placed at xy. Optionally, the text can be displayed in another position xytext. An arrow pointing from the text to the annotated point xy can then be added by defining arrowprops. Parameters textstr The text of the annotation. xy(float, float) The point (x, y) to annotate. The coordinate system is determined by xycoords. xytext(float, float), default: xy The position (x, y) to place the text at. The coordinate system is determined by textcoords. xycoordsstr or Artist or Transform or callable or (float, float), default: 'data' The coordinate system that xy is given in. The following types of values are supported: One of the following strings: Value Description 'figure points' Points from the lower left of the figure 'figure pixels' Pixels from the lower left of the figure 'figure fraction' Fraction of figure from lower left 'subfigure points' Points from the lower left of the subfigure 'subfigure pixels' Pixels from the lower left of the subfigure 'subfigure fraction' Fraction of subfigure from lower left 'axes points' Points from lower left corner of axes 'axes pixels' Pixels from lower left corner of axes 'axes fraction' Fraction of axes from lower left 'data' Use the coordinate system of the object being annotated (default) 'polar' (theta, r) if not native 'data' coordinates Note that 'subfigure pixels' and 'figure pixels' are the same for the parent figure, so users who want code that is usable in a subfigure can use 'subfigure pixels'. An Artist: xy is interpreted as a fraction of the artist's Bbox. E.g. (0, 0) would be the lower left corner of the bounding box and (0.5, 1) would be the center top of the bounding box. A Transform to transform xy to screen coordinates. A function with one of the following signatures: def transform(renderer) -> Bbox def transform(renderer) -> Transform where renderer is a RendererBase subclass. The result of the function is interpreted like the Artist and Transform cases above. A tuple (xcoords, ycoords) specifying separate coordinate systems for x and y. xcoords and ycoords must each be of one of the above described types. See Advanced Annotations for more details. textcoordsstr or Artist or Transform or callable or (float, float), default: value of xycoords The coordinate system that xytext is given in. All xycoords values are valid as well as the following strings: Value Description 'offset points' Offset (in points) from the xy value 'offset pixels' Offset (in pixels) from the xy value arrowpropsdict, optional The properties used to draw a FancyArrowPatch arrow between the positions xy and xytext. Defaults to None, i.e. no arrow is drawn. For historical reasons there are two different ways to specify arrows, "simple" and "fancy": Simple arrow: If arrowprops does not contain the key 'arrowstyle' the allowed keys are: Key Description width The width of the arrow in points headwidth The width of the base of the arrow head in points headlength The length of the arrow head in points shrink Fraction of total length to shrink from both ends ? Any key to matplotlib.patches.FancyArrowPatch The arrow is attached to the edge of the text box, the exact position (corners or centers) depending on where it's pointing to. Fancy arrow: This is used if 'arrowstyle' is provided in the arrowprops. Valid keys are the following FancyArrowPatch parameters: Key Description arrowstyle the arrow style connectionstyle the connection style relpos see below; default is (0.5, 0.5) patchA default is bounding box of the text patchB default is None shrinkA default is 2 points shrinkB default is 2 points mutation_scale default is text size (in points) mutation_aspect default is 1. ? any key for matplotlib.patches.PathPatch The exact starting point position of the arrow is defined by relpos. It's a tuple of relative coordinates of the text box, where (0, 0) is the lower left corner and (1, 1) is the upper right corner. Values <0 and >1 are supported and specify points outside the text box. By default (0.5, 0.5) the starting point is centered in the text box. annotation_clipbool or None, default: None Whether to draw the annotation when the annotation point xy is outside the axes area. If True, the annotation will only be drawn when xy is within the axes. If False, the annotation will always be drawn. If None, the annotation will only be drawn when xy is within the axes and xycoords is 'data'. **kwargs Additional kwargs are passed to Text. Returns Annotation See also Advanced Annotations propertyanncoords The coordinate system to use for Annotation.xyann. contains(event)[source] Return whether the mouse event occurred inside the axis-aligned bounding-box of the text. draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. get_anncoords()[source] Return the coordinate system to use for Annotation.xyann. See also xycoords in Annotation. get_tightbbox(renderer)[source] Like Artist.get_window_extent, but includes any clipping. Parameters rendererRendererBase subclass renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer()) Returns Bbox The enclosing bounding box (in figure pixel coordinates). get_window_extent(renderer=None)[source] Return the Bbox bounding the text, in display units. In addition to being used internally, this is useful for specifying clickable regions in a png file on a web page. Parameters rendererRenderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is only necessary to pass this argument when calling get_window_extent before the first draw. In practice, it is usually easier to trigger a draw first (e.g. by saving the figure). dpifloat, optional The dpi value for computing the bbox, defaults to self.figure.dpi (not the renderer dpi); should be set e.g. if to match regions with a figure saved with a custom dpi value. set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, anncoords=<UNSET>, annotation_clip=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool anncoords unknown annotation_clip bool or None backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None color or c color figure unknown fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float set_anncoords(coords)[source] Set the coordinate system to use for Annotation.xyann. See also xycoords in Annotation. set_figure(fig)[source] Set the Figure instance the artist belongs to. Parameters figFigure update_positions(renderer)[source] Update the pixel positions of the annotation text and the arrow patch. propertyxyann The text position. See also xytext in Annotation. propertyxycoords classmatplotlib.text.OffsetFrom(artist, ref_coord, unit='points')[source] Bases: object Callable helper class for working with Annotation. Parameters artistArtist or BboxBase or Transform The object to compute the offset from. ref_coord(float, float) If artist is an Artist or BboxBase, this values is the location to of the offset origin in fractions of the artist bounding box. If artist is a transform, the offset origin is the transform applied to this value. unit{'points, 'pixels'}, default: 'points' The screen units to use (pixels or points) for the offset input. get_unit()[source] Return the unit for input to the transform used by __call__. set_unit(unit)[source] Set the unit for input to the transform used by __call__. Parameters unit{'points', 'pixels'} classmatplotlib.text.Text(x=0, y=0, text='', color=None, verticalalignment='baseline', horizontalalignment='left', multialignment=None, fontproperties=None, rotation=None, linespacing=None, rotation_mode=None, usetex=None, wrap=False, transform_rotates_text=False, *, parse_math=True, **kwargs)[source] Bases: matplotlib.artist.Artist Handle storing and drawing of text in window or data coordinates. Create a Text instance at x, y with string text. Valid keyword arguments are: Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color or c color figure Figure fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float contains(mouseevent)[source] Return whether the mouse event occurred inside the axis-aligned bounding-box of the text. draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. get_bbox_patch()[source] Return the bbox Patch, or None if the patches.FancyBboxPatch is not made. get_c()[source] Alias for get_color. get_color()[source] Return the color of the text. get_family()[source] Alias for get_fontfamily. get_font()[source] Alias for get_fontproperties. get_font_properties()[source] Alias for get_fontproperties. get_fontfamily()[source] Return the list of font families used for font lookup. See also font_manager.FontProperties.get_family get_fontname()[source] Return the font name as a string. See also font_manager.FontProperties.get_name get_fontproperties()[source] Return the font_manager.FontProperties. get_fontsize()[source] Return the font size as an integer. See also font_manager.FontProperties.get_size_in_points get_fontstyle()[source] Return the font style as a string. See also font_manager.FontProperties.get_style get_fontvariant()[source] Return the font variant as a string. See also font_manager.FontProperties.get_variant get_fontweight()[source] Return the font weight as a string or a number. See also font_manager.FontProperties.get_weight get_ha()[source] Alias for get_horizontalalignment. get_horizontalalignment()[source] Return the horizontal alignment as a string. Will be one of 'left', 'center' or 'right'. get_math_fontfamily()[source] Return the font family name for math text rendered by Matplotlib. The default value is rcParams["mathtext.fontset"] (default: 'dejavusans'). See also set_math_fontfamily get_name()[source] Alias for get_fontname. get_parse_math()[source] Return whether mathtext parsing is considered for this Text. get_position()[source] Return the (x, y) position of the text. get_prop_tup(renderer=None)[source] [Deprecated] Return a hashable tuple of properties. Not intended to be human readable, but useful for backends who want to cache derived information about text (e.g., layouts) and need to know if the text has changed. Notes Deprecated since version 3.5. get_rotation()[source] Return the text angle in degrees between 0 and 360. get_rotation_mode()[source] Return the text rotation mode. get_size()[source] Alias for get_fontsize. get_stretch()[source] Return the font stretch as a string or a number. See also font_manager.FontProperties.get_stretch get_style()[source] Alias for get_fontstyle. get_text()[source] Return the text string. get_transform_rotates_text()[source] Return whether rotations of the transform affect the text direction. get_unitless_position()[source] Return the (x, y) unitless position of the text. get_usetex()[source] Return whether this Text object uses TeX for rendering. get_va()[source] Alias for get_verticalalignment. get_variant()[source] Alias for get_fontvariant. get_verticalalignment()[source] Return the vertical alignment as a string. Will be one of 'top', 'center', 'bottom', 'baseline' or 'center_baseline'. get_weight()[source] Alias for get_fontweight. get_window_extent(renderer=None, dpi=None)[source] Return the Bbox bounding the text, in display units. In addition to being used internally, this is useful for specifying clickable regions in a png file on a web page. Parameters rendererRenderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is only necessary to pass this argument when calling get_window_extent before the first draw. In practice, it is usually easier to trigger a draw first (e.g. by saving the figure). dpifloat, optional The dpi value for computing the bbox, defaults to self.figure.dpi (not the renderer dpi); should be set e.g. if to match regions with a figure saved with a custom dpi value. get_wrap()[source] Return whether the text can be wrapped. set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color color figure Figure fontfamily {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties font_manager.FontProperties or str or pathlib.Path fontsize float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle {'normal', 'italic', 'oblique'} fontvariant {'normal', 'small-caps'} fontweight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float set_backgroundcolor(color)[source] Set the background color of the text by updating the bbox. Parameters colorcolor See also set_bbox To change the position of the bounding box set_bbox(rectprops)[source] Draw a bounding box around self. Parameters rectpropsdict with properties for patches.FancyBboxPatch The default boxstyle is 'square'. The mutation scale of the patches.FancyBboxPatch is set to the fontsize. Examples t.set_bbox(dict(facecolor='red', alpha=0.5)) set_c(color)[source] Alias for set_color. set_clip_box(clipbox)[source] Set the artist's clip Bbox. Parameters clipboxBbox set_clip_on(b)[source] Set whether the artist uses clipping. When False artists will be visible outside of the axes which can lead to unexpected results. Parameters bbool set_clip_path(path, transform=None)[source] Set the artist's clip path. Parameters pathPatch or Path or TransformedPath or None The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed. transformTransform, optional Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform. Notes For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None. For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter. set_color(color)[source] Set the foreground color of the text Parameters colorcolor set_family(fontname)[source] Alias for set_fontfamily. set_font(fp)[source] Alias for set_fontproperties. set_font_properties(fp)[source] Alias for set_fontproperties. set_fontfamily(fontname)[source] Set the font family. May be either a single string, or a list of strings in decreasing priority. Each string may be either a real font name or a generic font class name. If the latter, the specific font names will be looked up in the corresponding rcParams. If a Text instance is constructed with fontfamily=None, then the font is set to rcParams["font.family"] (default: ['sans-serif']), and the same is done when set_fontfamily() is called on an existing Text instance. Parameters fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} See also font_manager.FontProperties.set_family set_fontname(fontname)[source] Alias for set_family. One-way alias only: the getter differs. Parameters fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} See also font_manager.FontProperties.set_family set_fontproperties(fp)[source] Set the font properties that control the text. Parameters fpfont_manager.FontProperties or str or pathlib.Path If a str, it is interpreted as a fontconfig pattern parsed by FontProperties. If a pathlib.Path, it is interpreted as the absolute path to a font file. set_fontsize(fontsize)[source] Set the font size. Parameters fontsizefloat or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} If float, the fontsize in points. The string values denote sizes relative to the default font size. See also font_manager.FontProperties.set_size set_fontstretch(stretch)[source] Set the font stretch (horizontal condensation or expansion). Parameters stretch{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} See also font_manager.FontProperties.set_stretch set_fontstyle(fontstyle)[source] Set the font style. Parameters fontstyle{'normal', 'italic', 'oblique'} See also font_manager.FontProperties.set_style set_fontvariant(variant)[source] Set the font variant. Parameters variant{'normal', 'small-caps'} See also font_manager.FontProperties.set_variant set_fontweight(weight)[source] Set the font weight. Parameters weight{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} See also font_manager.FontProperties.set_weight set_ha(align)[source] Alias for set_horizontalalignment. set_horizontalalignment(align)[source] Set the horizontal alignment to one of Parameters align{'center', 'right', 'left'} set_linespacing(spacing)[source] Set the line spacing as a multiple of the font size. The default line spacing is 1.2. Parameters spacingfloat (multiple of font size) set_ma(align)[source] Alias for set_multialignment. set_math_fontfamily(fontfamily)[source] Set the font family for math text rendered by Matplotlib. This does only affect Matplotlib's own math renderer. It has no effect when rendering with TeX (usetex=True). Parameters fontfamilystr The name of the font family. Available font families are defined in the matplotlibrc.template file. See also get_math_fontfamily set_multialignment(align)[source] Set the text alignment for multiline texts. The layout of the bounding box of all the lines is determined by the horizontalalignment and verticalalignment properties. This property controls the alignment of the text lines within that box. Parameters align{'left', 'right', 'center'} set_name(fontname)[source] Alias for set_fontname. set_parse_math(parse_math)[source] Override switch to disable any mathtext parsing for this Text. Parameters parse_mathbool If False, this Text will never use mathtext. If True, mathtext will be used if there is an even number of unescaped dollar signs. set_position(xy)[source] Set the (x, y) position of the text. Parameters xy(float, float) set_rotation(s)[source] Set the rotation of the text. Parameters sfloat or {'vertical', 'horizontal'} The rotation angle in degrees in mathematically positive direction (counterclockwise). 'horizontal' equals 0, 'vertical' equals 90. set_rotation_mode(m)[source] Set text rotation mode. Parameters m{None, 'default', 'anchor'} If None or "default", the text will be first rotated, then aligned according to their horizontal and vertical alignments. If "anchor", then alignment occurs before rotation. set_size(fontsize)[source] Alias for set_fontsize. set_stretch(stretch)[source] Alias for set_fontstretch. set_style(fontstyle)[source] Alias for set_fontstyle. set_text(s)[source] Set the text string s. It may contain newlines (\n) or math in LaTeX syntax. Parameters sobject Any object gets converted to its str representation, except for None which is converted to an empty string. set_transform_rotates_text(t)[source] Whether rotations of the transform affect the text direction. Parameters tbool set_usetex(usetex)[source] Parameters usetexbool or None Whether to render using TeX, None means to use rcParams["text.usetex"] (default: False). set_va(align)[source] Alias for set_verticalalignment. set_variant(variant)[source] Alias for set_fontvariant. set_verticalalignment(align)[source] Set the vertical alignment. Parameters align{'center', 'top', 'bottom', 'baseline', 'center_baseline'} set_weight(weight)[source] Alias for set_fontweight. set_wrap(wrap)[source] Set whether the text can be wrapped. Parameters wrapbool Notes Wrapping does not work together with savefig(..., bbox_inches='tight') (which is also used internally by %matplotlib inline in IPython/Jupyter). The 'tight' setting rescales the canvas to accommodate all content and happens before wrapping. set_x(x)[source] Set the x position of the text. Parameters xfloat set_y(y)[source] Set the y position of the text. Parameters yfloat update(kwargs)[source] Update this artist's properties from the dict props. Parameters propsdict update_bbox_position_size(renderer)[source] Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. update_from(other)[source] Copy properties from other to self. zorder=3 matplotlib.text.get_rotation(rotation)[source] Return rotation normalized to an angle between 0 and 360 degrees. Parameters rotationfloat or {None, 'horizontal', 'vertical'} Rotation angle in degrees. None and 'horizontal' equal 0, 'vertical' equals 90. Returns float
matplotlib.text_api
classmatplotlib.text.Annotation(text, xy, xytext=None, xycoords='data', textcoords=None, arrowprops=None, annotation_clip=None, **kwargs)[source] Bases: matplotlib.text.Text, matplotlib.text._AnnotationBase An Annotation is a Text that can refer to a specific position xy. Optionally an arrow pointing from the text to xy can be drawn. Attributes xy The annotated position. xycoords The coordinate system for xy. arrow_patch A FancyArrowPatch to point from xytext to xy. Annotate the point xy with text text. In the simplest form, the text is placed at xy. Optionally, the text can be displayed in another position xytext. An arrow pointing from the text to the annotated point xy can then be added by defining arrowprops. Parameters textstr The text of the annotation. xy(float, float) The point (x, y) to annotate. The coordinate system is determined by xycoords. xytext(float, float), default: xy The position (x, y) to place the text at. The coordinate system is determined by textcoords. xycoordsstr or Artist or Transform or callable or (float, float), default: 'data' The coordinate system that xy is given in. The following types of values are supported: One of the following strings: Value Description 'figure points' Points from the lower left of the figure 'figure pixels' Pixels from the lower left of the figure 'figure fraction' Fraction of figure from lower left 'subfigure points' Points from the lower left of the subfigure 'subfigure pixels' Pixels from the lower left of the subfigure 'subfigure fraction' Fraction of subfigure from lower left 'axes points' Points from lower left corner of axes 'axes pixels' Pixels from lower left corner of axes 'axes fraction' Fraction of axes from lower left 'data' Use the coordinate system of the object being annotated (default) 'polar' (theta, r) if not native 'data' coordinates Note that 'subfigure pixels' and 'figure pixels' are the same for the parent figure, so users who want code that is usable in a subfigure can use 'subfigure pixels'. An Artist: xy is interpreted as a fraction of the artist's Bbox. E.g. (0, 0) would be the lower left corner of the bounding box and (0.5, 1) would be the center top of the bounding box. A Transform to transform xy to screen coordinates. A function with one of the following signatures: def transform(renderer) -> Bbox def transform(renderer) -> Transform where renderer is a RendererBase subclass. The result of the function is interpreted like the Artist and Transform cases above. A tuple (xcoords, ycoords) specifying separate coordinate systems for x and y. xcoords and ycoords must each be of one of the above described types. See Advanced Annotations for more details. textcoordsstr or Artist or Transform or callable or (float, float), default: value of xycoords The coordinate system that xytext is given in. All xycoords values are valid as well as the following strings: Value Description 'offset points' Offset (in points) from the xy value 'offset pixels' Offset (in pixels) from the xy value arrowpropsdict, optional The properties used to draw a FancyArrowPatch arrow between the positions xy and xytext. Defaults to None, i.e. no arrow is drawn. For historical reasons there are two different ways to specify arrows, "simple" and "fancy": Simple arrow: If arrowprops does not contain the key 'arrowstyle' the allowed keys are: Key Description width The width of the arrow in points headwidth The width of the base of the arrow head in points headlength The length of the arrow head in points shrink Fraction of total length to shrink from both ends ? Any key to matplotlib.patches.FancyArrowPatch The arrow is attached to the edge of the text box, the exact position (corners or centers) depending on where it's pointing to. Fancy arrow: This is used if 'arrowstyle' is provided in the arrowprops. Valid keys are the following FancyArrowPatch parameters: Key Description arrowstyle the arrow style connectionstyle the connection style relpos see below; default is (0.5, 0.5) patchA default is bounding box of the text patchB default is None shrinkA default is 2 points shrinkB default is 2 points mutation_scale default is text size (in points) mutation_aspect default is 1. ? any key for matplotlib.patches.PathPatch The exact starting point position of the arrow is defined by relpos. It's a tuple of relative coordinates of the text box, where (0, 0) is the lower left corner and (1, 1) is the upper right corner. Values <0 and >1 are supported and specify points outside the text box. By default (0.5, 0.5) the starting point is centered in the text box. annotation_clipbool or None, default: None Whether to draw the annotation when the annotation point xy is outside the axes area. If True, the annotation will only be drawn when xy is within the axes. If False, the annotation will always be drawn. If None, the annotation will only be drawn when xy is within the axes and xycoords is 'data'. **kwargs Additional kwargs are passed to Text. Returns Annotation See also Advanced Annotations propertyanncoords The coordinate system to use for Annotation.xyann. contains(event)[source] Return whether the mouse event occurred inside the axis-aligned bounding-box of the text. draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. get_anncoords()[source] Return the coordinate system to use for Annotation.xyann. See also xycoords in Annotation. get_tightbbox(renderer)[source] Like Artist.get_window_extent, but includes any clipping. Parameters rendererRendererBase subclass renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer()) Returns Bbox The enclosing bounding box (in figure pixel coordinates). get_window_extent(renderer=None)[source] Return the Bbox bounding the text, in display units. In addition to being used internally, this is useful for specifying clickable regions in a png file on a web page. Parameters rendererRenderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is only necessary to pass this argument when calling get_window_extent before the first draw. In practice, it is usually easier to trigger a draw first (e.g. by saving the figure). dpifloat, optional The dpi value for computing the bbox, defaults to self.figure.dpi (not the renderer dpi); should be set e.g. if to match regions with a figure saved with a custom dpi value. set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, anncoords=<UNSET>, annotation_clip=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool anncoords unknown annotation_clip bool or None backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None color or c color figure unknown fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float set_anncoords(coords)[source] Set the coordinate system to use for Annotation.xyann. See also xycoords in Annotation. set_figure(fig)[source] Set the Figure instance the artist belongs to. Parameters figFigure update_positions(renderer)[source] Update the pixel positions of the annotation text and the arrow patch. propertyxyann The text position. See also xytext in Annotation. propertyxycoords
matplotlib.text_api#matplotlib.text.Annotation
contains(event)[source] Return whether the mouse event occurred inside the axis-aligned bounding-box of the text.
matplotlib.text_api#matplotlib.text.Annotation.contains
draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses.
matplotlib.text_api#matplotlib.text.Annotation.draw
get_anncoords()[source] Return the coordinate system to use for Annotation.xyann. See also xycoords in Annotation.
matplotlib.text_api#matplotlib.text.Annotation.get_anncoords
get_tightbbox(renderer)[source] Like Artist.get_window_extent, but includes any clipping. Parameters rendererRendererBase subclass renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer()) Returns Bbox The enclosing bounding box (in figure pixel coordinates).
matplotlib.text_api#matplotlib.text.Annotation.get_tightbbox
get_window_extent(renderer=None)[source] Return the Bbox bounding the text, in display units. In addition to being used internally, this is useful for specifying clickable regions in a png file on a web page. Parameters rendererRenderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is only necessary to pass this argument when calling get_window_extent before the first draw. In practice, it is usually easier to trigger a draw first (e.g. by saving the figure). dpifloat, optional The dpi value for computing the bbox, defaults to self.figure.dpi (not the renderer dpi); should be set e.g. if to match regions with a figure saved with a custom dpi value.
matplotlib.text_api#matplotlib.text.Annotation.get_window_extent
set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, anncoords=<UNSET>, annotation_clip=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool anncoords unknown annotation_clip bool or None backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box Bbox clip_on bool clip_path Patch or (Path, Transform) or None color or c color figure unknown fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float
matplotlib.text_api#matplotlib.text.Annotation.set
set_anncoords(coords)[source] Set the coordinate system to use for Annotation.xyann. See also xycoords in Annotation.
matplotlib.text_api#matplotlib.text.Annotation.set_anncoords
set_figure(fig)[source] Set the Figure instance the artist belongs to. Parameters figFigure
matplotlib.text_api#matplotlib.text.Annotation.set_figure
update_positions(renderer)[source] Update the pixel positions of the annotation text and the arrow patch.
matplotlib.text_api#matplotlib.text.Annotation.update_positions
matplotlib.text.get_rotation(rotation)[source] Return rotation normalized to an angle between 0 and 360 degrees. Parameters rotationfloat or {None, 'horizontal', 'vertical'} Rotation angle in degrees. None and 'horizontal' equal 0, 'vertical' equals 90. Returns float
matplotlib.text_api#matplotlib.text.get_rotation
classmatplotlib.text.OffsetFrom(artist, ref_coord, unit='points')[source] Bases: object Callable helper class for working with Annotation. Parameters artistArtist or BboxBase or Transform The object to compute the offset from. ref_coord(float, float) If artist is an Artist or BboxBase, this values is the location to of the offset origin in fractions of the artist bounding box. If artist is a transform, the offset origin is the transform applied to this value. unit{'points, 'pixels'}, default: 'points' The screen units to use (pixels or points) for the offset input. get_unit()[source] Return the unit for input to the transform used by __call__. set_unit(unit)[source] Set the unit for input to the transform used by __call__. Parameters unit{'points', 'pixels'}
matplotlib.text_api#matplotlib.text.OffsetFrom
get_unit()[source] Return the unit for input to the transform used by __call__.
matplotlib.text_api#matplotlib.text.OffsetFrom.get_unit
set_unit(unit)[source] Set the unit for input to the transform used by __call__. Parameters unit{'points', 'pixels'}
matplotlib.text_api#matplotlib.text.OffsetFrom.set_unit
classmatplotlib.text.Text(x=0, y=0, text='', color=None, verticalalignment='baseline', horizontalalignment='left', multialignment=None, fontproperties=None, rotation=None, linespacing=None, rotation_mode=None, usetex=None, wrap=False, transform_rotates_text=False, *, parse_math=True, **kwargs)[source] Bases: matplotlib.artist.Artist Handle storing and drawing of text in window or data coordinates. Create a Text instance at x, y with string text. Valid keyword arguments are: Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color or c color figure Figure fontfamily or family {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties or font or font_properties font_manager.FontProperties or str or pathlib.Path fontsize or size float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch or stretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle or style {'normal', 'italic', 'oblique'} fontvariant or variant {'normal', 'small-caps'} fontweight or weight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment or ha {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment or ma {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment or va {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float contains(mouseevent)[source] Return whether the mouse event occurred inside the axis-aligned bounding-box of the text. draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses. get_bbox_patch()[source] Return the bbox Patch, or None if the patches.FancyBboxPatch is not made. get_c()[source] Alias for get_color. get_color()[source] Return the color of the text. get_family()[source] Alias for get_fontfamily. get_font()[source] Alias for get_fontproperties. get_font_properties()[source] Alias for get_fontproperties. get_fontfamily()[source] Return the list of font families used for font lookup. See also font_manager.FontProperties.get_family get_fontname()[source] Return the font name as a string. See also font_manager.FontProperties.get_name get_fontproperties()[source] Return the font_manager.FontProperties. get_fontsize()[source] Return the font size as an integer. See also font_manager.FontProperties.get_size_in_points get_fontstyle()[source] Return the font style as a string. See also font_manager.FontProperties.get_style get_fontvariant()[source] Return the font variant as a string. See also font_manager.FontProperties.get_variant get_fontweight()[source] Return the font weight as a string or a number. See also font_manager.FontProperties.get_weight get_ha()[source] Alias for get_horizontalalignment. get_horizontalalignment()[source] Return the horizontal alignment as a string. Will be one of 'left', 'center' or 'right'. get_math_fontfamily()[source] Return the font family name for math text rendered by Matplotlib. The default value is rcParams["mathtext.fontset"] (default: 'dejavusans'). See also set_math_fontfamily get_name()[source] Alias for get_fontname. get_parse_math()[source] Return whether mathtext parsing is considered for this Text. get_position()[source] Return the (x, y) position of the text. get_prop_tup(renderer=None)[source] [Deprecated] Return a hashable tuple of properties. Not intended to be human readable, but useful for backends who want to cache derived information about text (e.g., layouts) and need to know if the text has changed. Notes Deprecated since version 3.5. get_rotation()[source] Return the text angle in degrees between 0 and 360. get_rotation_mode()[source] Return the text rotation mode. get_size()[source] Alias for get_fontsize. get_stretch()[source] Return the font stretch as a string or a number. See also font_manager.FontProperties.get_stretch get_style()[source] Alias for get_fontstyle. get_text()[source] Return the text string. get_transform_rotates_text()[source] Return whether rotations of the transform affect the text direction. get_unitless_position()[source] Return the (x, y) unitless position of the text. get_usetex()[source] Return whether this Text object uses TeX for rendering. get_va()[source] Alias for get_verticalalignment. get_variant()[source] Alias for get_fontvariant. get_verticalalignment()[source] Return the vertical alignment as a string. Will be one of 'top', 'center', 'bottom', 'baseline' or 'center_baseline'. get_weight()[source] Alias for get_fontweight. get_window_extent(renderer=None, dpi=None)[source] Return the Bbox bounding the text, in display units. In addition to being used internally, this is useful for specifying clickable regions in a png file on a web page. Parameters rendererRenderer, optional A renderer is needed to compute the bounding box. If the artist has already been drawn, the renderer is cached; thus, it is only necessary to pass this argument when calling get_window_extent before the first draw. In practice, it is usually easier to trigger a draw first (e.g. by saving the figure). dpifloat, optional The dpi value for computing the bbox, defaults to self.figure.dpi (not the renderer dpi); should be set e.g. if to match regions with a figure saved with a custom dpi value. get_wrap()[source] Return whether the text can be wrapped. set(*, agg_filter=<UNSET>, alpha=<UNSET>, animated=<UNSET>, backgroundcolor=<UNSET>, bbox=<UNSET>, clip_box=<UNSET>, clip_on=<UNSET>, clip_path=<UNSET>, color=<UNSET>, fontfamily=<UNSET>, fontproperties=<UNSET>, fontsize=<UNSET>, fontstretch=<UNSET>, fontstyle=<UNSET>, fontvariant=<UNSET>, fontweight=<UNSET>, gid=<UNSET>, horizontalalignment=<UNSET>, in_layout=<UNSET>, label=<UNSET>, linespacing=<UNSET>, math_fontfamily=<UNSET>, multialignment=<UNSET>, parse_math=<UNSET>, path_effects=<UNSET>, picker=<UNSET>, position=<UNSET>, rasterized=<UNSET>, rotation=<UNSET>, rotation_mode=<UNSET>, sketch_params=<UNSET>, snap=<UNSET>, text=<UNSET>, transform=<UNSET>, transform_rotates_text=<UNSET>, url=<UNSET>, usetex=<UNSET>, verticalalignment=<UNSET>, visible=<UNSET>, wrap=<UNSET>, x=<UNSET>, y=<UNSET>, zorder=<UNSET>)[source] Set multiple properties at once. Supported properties are Property Description agg_filter a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha scalar or None animated bool backgroundcolor color bbox dict with properties for patches.FancyBboxPatch clip_box unknown clip_on unknown clip_path unknown color color figure Figure fontfamily {FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} fontproperties font_manager.FontProperties or str or pathlib.Path fontsize float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} fontstretch {a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} fontstyle {'normal', 'italic', 'oblique'} fontvariant {'normal', 'small-caps'} fontweight {a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} gid str horizontalalignment {'center', 'right', 'left'} in_layout bool label object linespacing float (multiple of font size) math_fontfamily str multialignment {'left', 'right', 'center'} parse_math bool path_effects AbstractPathEffect picker None or bool or float or callable position (float, float) rasterized bool rotation float or {'vertical', 'horizontal'} rotation_mode {None, 'default', 'anchor'} sketch_params (scale: float, length: float, randomness: float) snap bool or None text object transform Transform transform_rotates_text bool url str usetex bool or None verticalalignment {'center', 'top', 'bottom', 'baseline', 'center_baseline'} visible bool wrap bool x float y float zorder float set_backgroundcolor(color)[source] Set the background color of the text by updating the bbox. Parameters colorcolor See also set_bbox To change the position of the bounding box set_bbox(rectprops)[source] Draw a bounding box around self. Parameters rectpropsdict with properties for patches.FancyBboxPatch The default boxstyle is 'square'. The mutation scale of the patches.FancyBboxPatch is set to the fontsize. Examples t.set_bbox(dict(facecolor='red', alpha=0.5)) set_c(color)[source] Alias for set_color. set_clip_box(clipbox)[source] Set the artist's clip Bbox. Parameters clipboxBbox set_clip_on(b)[source] Set whether the artist uses clipping. When False artists will be visible outside of the axes which can lead to unexpected results. Parameters bbool set_clip_path(path, transform=None)[source] Set the artist's clip path. Parameters pathPatch or Path or TransformedPath or None The clip path. If given a Path, transform must be provided as well. If None, a previously set clip path is removed. transformTransform, optional Only used if path is a Path, in which case the given Path is converted to a TransformedPath using transform. Notes For efficiency, if path is a Rectangle this method will set the clipping box to the corresponding rectangle and set the clipping path to None. For technical reasons (support of set), a tuple (path, transform) is also accepted as a single positional parameter. set_color(color)[source] Set the foreground color of the text Parameters colorcolor set_family(fontname)[source] Alias for set_fontfamily. set_font(fp)[source] Alias for set_fontproperties. set_font_properties(fp)[source] Alias for set_fontproperties. set_fontfamily(fontname)[source] Set the font family. May be either a single string, or a list of strings in decreasing priority. Each string may be either a real font name or a generic font class name. If the latter, the specific font names will be looked up in the corresponding rcParams. If a Text instance is constructed with fontfamily=None, then the font is set to rcParams["font.family"] (default: ['sans-serif']), and the same is done when set_fontfamily() is called on an existing Text instance. Parameters fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} See also font_manager.FontProperties.set_family set_fontname(fontname)[source] Alias for set_family. One-way alias only: the getter differs. Parameters fontname{FONTNAME, 'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace'} See also font_manager.FontProperties.set_family set_fontproperties(fp)[source] Set the font properties that control the text. Parameters fpfont_manager.FontProperties or str or pathlib.Path If a str, it is interpreted as a fontconfig pattern parsed by FontProperties. If a pathlib.Path, it is interpreted as the absolute path to a font file. set_fontsize(fontsize)[source] Set the font size. Parameters fontsizefloat or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'} If float, the fontsize in points. The string values denote sizes relative to the default font size. See also font_manager.FontProperties.set_size set_fontstretch(stretch)[source] Set the font stretch (horizontal condensation or expansion). Parameters stretch{a numeric value in range 0-1000, 'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed', 'normal', 'semi-expanded', 'expanded', 'extra-expanded', 'ultra-expanded'} See also font_manager.FontProperties.set_stretch set_fontstyle(fontstyle)[source] Set the font style. Parameters fontstyle{'normal', 'italic', 'oblique'} See also font_manager.FontProperties.set_style set_fontvariant(variant)[source] Set the font variant. Parameters variant{'normal', 'small-caps'} See also font_manager.FontProperties.set_variant set_fontweight(weight)[source] Set the font weight. Parameters weight{a numeric value in range 0-1000, 'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black'} See also font_manager.FontProperties.set_weight set_ha(align)[source] Alias for set_horizontalalignment. set_horizontalalignment(align)[source] Set the horizontal alignment to one of Parameters align{'center', 'right', 'left'} set_linespacing(spacing)[source] Set the line spacing as a multiple of the font size. The default line spacing is 1.2. Parameters spacingfloat (multiple of font size) set_ma(align)[source] Alias for set_multialignment. set_math_fontfamily(fontfamily)[source] Set the font family for math text rendered by Matplotlib. This does only affect Matplotlib's own math renderer. It has no effect when rendering with TeX (usetex=True). Parameters fontfamilystr The name of the font family. Available font families are defined in the matplotlibrc.template file. See also get_math_fontfamily set_multialignment(align)[source] Set the text alignment for multiline texts. The layout of the bounding box of all the lines is determined by the horizontalalignment and verticalalignment properties. This property controls the alignment of the text lines within that box. Parameters align{'left', 'right', 'center'} set_name(fontname)[source] Alias for set_fontname. set_parse_math(parse_math)[source] Override switch to disable any mathtext parsing for this Text. Parameters parse_mathbool If False, this Text will never use mathtext. If True, mathtext will be used if there is an even number of unescaped dollar signs. set_position(xy)[source] Set the (x, y) position of the text. Parameters xy(float, float) set_rotation(s)[source] Set the rotation of the text. Parameters sfloat or {'vertical', 'horizontal'} The rotation angle in degrees in mathematically positive direction (counterclockwise). 'horizontal' equals 0, 'vertical' equals 90. set_rotation_mode(m)[source] Set text rotation mode. Parameters m{None, 'default', 'anchor'} If None or "default", the text will be first rotated, then aligned according to their horizontal and vertical alignments. If "anchor", then alignment occurs before rotation. set_size(fontsize)[source] Alias for set_fontsize. set_stretch(stretch)[source] Alias for set_fontstretch. set_style(fontstyle)[source] Alias for set_fontstyle. set_text(s)[source] Set the text string s. It may contain newlines (\n) or math in LaTeX syntax. Parameters sobject Any object gets converted to its str representation, except for None which is converted to an empty string. set_transform_rotates_text(t)[source] Whether rotations of the transform affect the text direction. Parameters tbool set_usetex(usetex)[source] Parameters usetexbool or None Whether to render using TeX, None means to use rcParams["text.usetex"] (default: False). set_va(align)[source] Alias for set_verticalalignment. set_variant(variant)[source] Alias for set_fontvariant. set_verticalalignment(align)[source] Set the vertical alignment. Parameters align{'center', 'top', 'bottom', 'baseline', 'center_baseline'} set_weight(weight)[source] Alias for set_fontweight. set_wrap(wrap)[source] Set whether the text can be wrapped. Parameters wrapbool Notes Wrapping does not work together with savefig(..., bbox_inches='tight') (which is also used internally by %matplotlib inline in IPython/Jupyter). The 'tight' setting rescales the canvas to accommodate all content and happens before wrapping. set_x(x)[source] Set the x position of the text. Parameters xfloat set_y(y)[source] Set the y position of the text. Parameters yfloat update(kwargs)[source] Update this artist's properties from the dict props. Parameters propsdict update_bbox_position_size(renderer)[source] Update the location and the size of the bbox. This method should be used when the position and size of the bbox needs to be updated before actually drawing the bbox. update_from(other)[source] Copy properties from other to self. zorder=3
matplotlib.text_api#matplotlib.text.Text
contains(mouseevent)[source] Return whether the mouse event occurred inside the axis-aligned bounding-box of the text.
matplotlib.text_api#matplotlib.text.Text.contains
draw(renderer)[source] 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). Parameters rendererRendererBase subclass. Notes This method is overridden in the Artist subclasses.
matplotlib.text_api#matplotlib.text.Text.draw
get_bbox_patch()[source] Return the bbox Patch, or None if the patches.FancyBboxPatch is not made.
matplotlib.text_api#matplotlib.text.Text.get_bbox_patch
get_c()[source] Alias for get_color.
matplotlib.text_api#matplotlib.text.Text.get_c
get_color()[source] Return the color of the text.
matplotlib.text_api#matplotlib.text.Text.get_color
get_family()[source] Alias for get_fontfamily.
matplotlib.text_api#matplotlib.text.Text.get_family
get_font()[source] Alias for get_fontproperties.
matplotlib.text_api#matplotlib.text.Text.get_font
get_font_properties()[source] Alias for get_fontproperties.
matplotlib.text_api#matplotlib.text.Text.get_font_properties
get_fontfamily()[source] Return the list of font families used for font lookup. See also font_manager.FontProperties.get_family
matplotlib.text_api#matplotlib.text.Text.get_fontfamily
get_fontname()[source] Return the font name as a string. See also font_manager.FontProperties.get_name
matplotlib.text_api#matplotlib.text.Text.get_fontname
get_fontproperties()[source] Return the font_manager.FontProperties.
matplotlib.text_api#matplotlib.text.Text.get_fontproperties
get_fontsize()[source] Return the font size as an integer. See also font_manager.FontProperties.get_size_in_points
matplotlib.text_api#matplotlib.text.Text.get_fontsize