Container classes for Artist
s.
OffsetBox
The base of all container artists defined in this module.
AnchoredOffsetbox
, AnchoredText
Anchor and align an arbitrary Artist
or a text relative to the parent axes or a specific anchor point.
DrawingArea
A container with fixed width and height. Children have a fixed position inside the container and may be clipped.
HPacker
, VPacker
Containers for layouting their children vertically or horizontally.
PaddedBox
A container to add a padding around an Artist
.
TextArea
Contains a single Text
instance.
Bases: matplotlib.offsetbox.OffsetBox
An offset box placed according to location loc.
AnchoredOffsetbox has a single child. When multiple children are needed, use an extra OffsetBox to enclose them. By default, the offset box is anchored against its parent axes. You may explicitly specify the bbox_to_anchor.
The box location. Valid locations are 'upper left', 'upper center', 'upper right', 'center left', 'center', 'center right', 'lower left', 'lower center, 'lower right'. For backward compatibility, numeric values are accepted as well. See the parameter loc of Legend
for details.
Padding around the child as fraction of the fontsize.
Padding between the offsetbox frame and the bbox_to_anchor.
OffsetBox
The box that will be anchored.
FontProperties
This is only used as a reference for paddings. If not given, rcParams["legend.fontsize"]
(default: 'medium'
) is used.
Whether to draw a frame around the box.
BboxBase
, 2-tuple, or 4-tuple of floats
Box that is used to position the legend in conjunction with loc.
matplotlib.transforms.Transform
The transform for the bounding box (bbox_to_anchor).
All other parameters are passed on to OffsetBox
.
See Legend
for a detailed description of the anchoring mechanism.
Update the location of children if necessary and draw them to the given renderer.
Return the bbox that the box is anchored to.
Return the child.
Return the list of children.
Return the extent of the box as (width, height, x, y).
This is the extent of the child plus the padding.
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
unknown | |
unknown | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
Set the bbox that the box is anchored to.
bbox can be a Bbox instance, a list of [left, bottom, width, height], or a list of [left, bottom] where the width and height will be assumed to be zero. The bbox will be transformed to display coordinate by the given transform.
Set the child to be anchored.
Bases: matplotlib.offsetbox.AnchoredOffsetbox
AnchoredOffsetbox with Text.
Text.
Location code. See AnchoredOffsetbox
.
Padding around the text as fraction of the fontsize.
Spacing between the offsetbox frame and the bbox_to_anchor.
Dictionary of keyword parameters to be passed to the Text
instance contained inside AnchoredText.
All other parameters are passed to AnchoredOffsetbox
.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
unknown | |
unknown | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
Bases: matplotlib.artist.Artist
, matplotlib.text._AnnotationBase
Container for an OffsetBox
referring to a specific position xy.
Optionally an arrow pointing from the offsetbox to xy can be drawn.
This is like Annotation
, but with OffsetBox
instead of Text
.
OffsetBox
The point (x, y) to annotate. The coordinate system is determined by xycoords.
The position (x, y) to place the text at. The coordinate system is determined by boxcoords.
Artist
or Transform
or callable or (float, float), default: 'data'
The coordinate system that xy is given in. See the parameter xycoords in Annotation
for a detailed description.
Artist
or Transform
or callable or (float, float), default: value of xycoords
The coordinate system that xybox is given in. See the parameter textcoords in Annotation
for a detailed description.
Whether to draw a frame around the box.
Padding around the offsetbox.
A tuple of two floats for a vertical and horizontal alignment of the offset box w.r.t. the boxcoords. The lower-left corner is (0, 0) and upper-right corner is (1, 1).
Other parameters are identical to Annotation
.
Test whether the artist contains the mouse event.
matplotlib.backend_bases.MouseEvent
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.
Draw the Artist (and its children) using the given renderer.
This has no effect if the artist is not visible (Artist.get_visible
returns False).
RendererBase
subclass.
This method is overridden in the Artist subclasses.
Return the fontsize in points.
Like Artist.get_window_extent
, but includes any clipping.
RendererBase
subclass
renderer that will be used to draw the figures (i.e. fig.canvas.get_renderer()
)
Bbox
The enclosing bounding box (in figure pixel coordinates).
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
| bool or None |
bool | |
Patch or (Path, Transform) or None | |
unknown | |
unknown | |
str | |
bool | |
object | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float |
Set the fontsize in points.
If s is not given, reset to rcParams["legend.fontsize"]
(default: 'medium'
).
Update the pixel positions of the annotated point and the text.
Bases: matplotlib.offsetbox.OffsetBox
Offset Box with the aux_transform. Its children will be transformed with the aux_transform first then will be offsetted. The absolute coordinate of the aux_transform is meaning as it will be automatically adjust so that the left-lower corner of the bounding box of children will be set to (0, 0) before the offset transform.
It is similar to drawing area, except that the extent of the box is not predetermined but calculated from the window extent of its children. Furthermore, the extent of the children will be calculated in the transformed coordinate.
Update the location of children if necessary and draw them to the given renderer.
Return a tuple width, height, xdescent, ydescent
of the box.
Return offset of the container.
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
unknown | |
str | |
bool | |
float | |
float |
Set the offset of the container.
The (x, y) coordinates of the offset in display units.
set_transform is ignored.
Bases: matplotlib.offsetbox.DraggableBase
Bases: object
Helper base class for a draggable artist (legend, offsetbox).
Derived classes must override the following methods:
def save_offset(self): ''' Called when the object is picked for dragging; should save the reference position of the artist. ''' def update_offset(self, dx, dy): ''' Called during the dragging; (*dx*, *dy*) is the pixel offset from the point where the mouse drag started. '''
Optionally, you may override the following method:
def finalize_offset(self): '''Called when the mouse is released.'''
In the current implementation of DraggableLegend
and DraggableAnnotation
, update_offset
places the artists in display coordinates, and finalize_offset
recalculates their position in axes coordinate and set a relevant attribute.
Disconnect the callbacks.
Bases: matplotlib.offsetbox.DraggableBase
Bases: matplotlib.offsetbox.OffsetBox
The DrawingArea can contain any Artist as a child. The DrawingArea has a fixed width and height. The position of children relative to the parent is fixed. The children can be clipped at the boundaries of the parent.
Width and height of the container box.
Descent of the box in x- and y-direction.
Whether to clip the children to the box.
If the children of this DrawingArea should be clipped by DrawingArea bounding box.
Update the location of children if necessary and draw them to the given renderer.
Return width, height, xdescent, ydescent of box.
Return offset of the container.
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
unknown | |
str | |
bool | |
float | |
float |
Set the offset of the container.
The (x, y) coordinates of the offset in display units.
set_transform is ignored.
Bases: matplotlib.offsetbox.PackerBase
HPacker packs its children horizontally, automatically adjusting their relative positions at draw time.
The boundary padding in points.
The spacing between items in points.
Width and height of the container box in pixels, calculated if None.
Alignment of boxes.
The packing mode.
Artist
s tight with sep spacing.Artist
The artists to pack.
pad and sep are in points and will be scaled with the renderer dpi, while width and height are in pixels.
Update offset of the children and return the extent of the box.
RendererBase
subclass
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
Bases: matplotlib.artist.Artist
The OffsetBox is a simple container artist.
The child artists are meant to be drawn at a relative position to its parent.
Being an artist itself, all parameters are passed on to Artist
.
The Axes
instance the artist resides in, or None.
Delegate the mouse event contains-check to the children.
As a container, the OffsetBox
does not respond itself to mouseevents.
matplotlib.backend_bases.MouseEvent
Whether any values are within the radius.
An artist-specific dictionary of details of the event context, such as which points are contained in the pick radius. See the individual Artist subclasses for details.
See also
Update the location of children if necessary and draw them to the given renderer.
Return a tuple width, height, xdescent, ydescent
of the box.
Update offset of the children and return the extent of the box.
RendererBase
subclass
Return the offset as a tuple (x, y).
The extent parameters have to be provided to handle the case where the offset is dynamically determined by a callable (see set_offset
).
Extent parameters.
RendererBase
subclass
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
Set the height of the box.
Set the offset.
The (x, y) coordinates of the offset in display units. These can either be given explicitly as a tuple (x, y), or by providing a function that converts the extent into the offset. This function must have the signature:
def offset(width, height, xdescent, ydescent, renderer) -> (float, float)
Set the width of the box.
Bases: matplotlib.offsetbox.OffsetBox
Update the location of children if necessary and draw them to the given renderer.
Return a tuple width, height, xdescent, ydescent
of the box.
Return offset of the container.
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
unknown | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
unknown | |
float |
Bases: matplotlib.offsetbox.OffsetBox
The boundary padding in points.
The spacing between items in points.
Width and height of the container box in pixels, calculated if None.
Alignment of boxes.
The packing mode.
Artist
s tight with sep spacing.Artist
The artists to pack.
pad and sep are in points and will be scaled with the renderer dpi, while width and height are in pixels.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
Bases: matplotlib.offsetbox.OffsetBox
A container to add a padding around an Artist
.
The PaddedBox
contains a FancyBboxPatch
that is used to visualize it when rendering.
Artist
The contained Artist
.
The padding in points. This will be scaled with the renderer dpi. In contrast width and height are in pixels and thus not scaled.
Whether to draw the contained FancyBboxPatch
.
Additional parameters passed to the contained FancyBboxPatch
.
Update the location of children if necessary and draw them to the given renderer.
Update offset of the children and return the extent of the box.
RendererBase
subclass
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
Bases: matplotlib.offsetbox.OffsetBox
The TextArea is a container artist for a single Text instance.
The text is placed at (0, 0) with baseline+left alignment, by default. The width and height of the TextArea instance is the width and height of its child text.
The text to be displayed.
Dictionary of keyword parameters to be passed to the Text
instance in the TextArea.
Whether the baseline for multiline text is adjusted so that it is (approximately) center-aligned with single-line text.
If True
, the box has a minimum descent of "p". This is now effectively always True.
Update the location of children if necessary and draw them to the given renderer.
Return a tuple width, height, xdescent, ydescent
of the box.
[Deprecated] Get minimumdescent.
Deprecated since version 3.4.
Get multilinebaseline.
Return offset of the container.
Return the string representation of this area's text.
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.
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
unknown | |
unknown | |
(float, float) | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
unknown | |
unknown | |
str | |
bool | |
float | |
float |
[Deprecated] Set minimumdescent.
If True, extent of the single line text is adjusted so that its descent is at least the one of the glyph "p".
Deprecated since version 3.4.
Set multilinebaseline.
If True, the baseline for multiline text is adjusted so that it is (approximately) center-aligned with single-line text. This is used e.g. by the legend implementation so that single-line labels are baseline-aligned, but multiline labels are "center"-aligned with them.
Set the offset of the container.
The (x, y) coordinates of the offset in display units.
Set the text of this area as a string.
set_transform is ignored.
Bases: matplotlib.offsetbox.PackerBase
VPacker packs its children vertically, automatically adjusting their relative positions at draw time.
The boundary padding in points.
The spacing between items in points.
Width and height of the container box in pixels, calculated if None.
Alignment of boxes.
The packing mode.
Artist
s tight with sep spacing.Artist
The artists to pack.
pad and sep are in points and will be scaled with the renderer dpi, while width and height are in pixels.
Update offset of the children and return the extent of the box.
RendererBase
subclass
Set multiple properties at once.
Supported properties are
Property | Description |
---|---|
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array | |
scalar or None | |
bool | |
bool | |
Patch or (Path, Transform) or None | |
str | |
float | |
bool | |
object | |
(float, float) or callable | |
None or bool or float or callable | |
bool | |
(scale: float, length: float, randomness: float) | |
bool or None | |
str | |
bool | |
float | |
float |
© 2012–2021 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.5.1/api/offsetbox_api.html