matplotlib.offsetbox
#
Container classes forArtist
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 parentaxes or a specific anchor point.DrawingArea
A container with fixed width and height. Children have a fixed positioninside 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.
- classmatplotlib.offsetbox.AnchoredOffsetbox(loc,*,pad=0.4,borderpad=0.5,child=None,prop=None,frameon=True,bbox_to_anchor=None,bbox_transform=None,**kwargs)[source]#
Bases:
OffsetBox
An OffsetBox placed according to locationloc.
AnchoredOffsetbox has a single child. When multiple children are needed,use an extra OffsetBox to enclose them. By default, the offset box isanchored against its parent Axes. You may explicitly specify thebbox_to_anchor.
- Parameters:
- locstr
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 parameterloc of
Legend
for details.- padfloat, default: 0.4
Padding around the child as fraction of the fontsize.
- borderpadfloat or (float, float), default: 0.5
Padding between the offsetbox frame and thebbox_to_anchor.If a float, the same padding is used for both x and y.If a tuple of two floats, it specifies the (x, y) padding.
Added in version 3.11:Theborderpad parameter now accepts a tuple of (x, y) paddings.
- child
OffsetBox
The box that will be anchored.
- prop
FontProperties
This is only used as a reference for paddings. If not given,
rcParams["legend.fontsize"]
(default:'medium'
) is used.- frameonbool
Whether to draw a frame around the box.
- bbox_to_anchor
BboxBase
, 2-tuple, or 4-tuple of floats Box that is used to position the legend in conjunction withloc.
- bbox_transformNone or
matplotlib.transforms.Transform
The transform for the bounding box (bbox_to_anchor).
- **kwargs
All other parameters are passed on to
OffsetBox
.
Notes
See
Legend
for a detailed description of the anchoring mechanism.- codes={'center':10,'centerleft':6,'centerright':7,'lowercenter':8,'lowerleft':3,'lowerright':4,'right':5,'uppercenter':9,'upperleft':2,'upperright':1}#
- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- get_offset(bbox,renderer)[source]#
Return the offset as a tuple (x, y).
The extent parameters have to be provided to handle the case where theoffset is dynamically determined by a callable (see
set_offset
).- Parameters:
- bbox
Bbox
- renderer
RendererBase
subclass
- bbox
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,bbox_to_anchor=<UNSET>,child=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
unknown
unknown
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float
- set_bbox_to_anchor(bbox,transform=None)[source]#
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 andheight will be assumed to be zero. The bbox will betransformed to display coordinate by the given transform.
- zorder=5#
- classmatplotlib.offsetbox.AnchoredText(s,loc,*,pad=0.4,borderpad=0.5,prop=None,**kwargs)[source]#
Bases:
AnchoredOffsetbox
AnchoredOffsetbox with Text.
- Parameters:
- sstr
Text.
- locstr
Location code. See
AnchoredOffsetbox
.- padfloat, default: 0.4
Padding around the text as fraction of the fontsize.
- borderpadfloat, default: 0.5
Spacing between the offsetbox frame and thebbox_to_anchor.
- propdict, optional
Dictionary of keyword parameters to be passed to the
Text
instance contained inside AnchoredText.- **kwargs
All other parameters are passed to
AnchoredOffsetbox
.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,bbox_to_anchor=<UNSET>,child=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
unknown
unknown
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float
- classmatplotlib.offsetbox.AnnotationBbox(offsetbox,xy,xybox=None,xycoords='data',boxcoords=None,*,frameon=True,pad=0.4,annotation_clip=None,box_alignment=(0.5,0.5),bboxprops=None,arrowprops=None,fontsize=None,**kwargs)[source]#
Bases:
Artist
,_AnnotationBase
Container for an
OffsetBox
referring to a specific positionxy.Optionally an arrow pointing from the offsetbox toxy can be drawn.
This is like
Annotation
, but withOffsetBox
instead ofText
.- Parameters:
- offsetbox
OffsetBox
- xy(float, float)
The point(x, y) to annotate. The coordinate system is determinedbyxycoords.
- xybox(float, float), default:xy
The position(x, y) to place the text at. The coordinate systemis determined byboxcoords.
- xycoordssingle or two-tuple of str or
Artist
orTransform
or callable, default: 'data' The coordinate system thatxy is given in. See the parameterxycoords in
Annotation
for a detailed description.- boxcoordssingle or two-tuple of str or
Artist
orTransform
or callable, default: value ofxycoords The coordinate system thatxybox is given in. See the parametertextcoords in
Annotation
for a detailed description.- frameonbool, default: True
By default, the text is surrounded by a white
FancyBboxPatch
(accessible as thepatch
attribute of theAnnotationBbox
).Ifframeon is set to False, this patch is made invisible.- annotation_clip: bool or None, default: None
Whether to clip (i.e. not draw) the annotation when the annotationpointxy is outside the Axes area.
IfTrue, the annotation will be clipped whenxy is outsidethe Axes.
IfFalse, the annotation will always be drawn.
IfNone, the annotation will be clipped whenxy is outsidethe Axes andxycoords is 'data'.
- padfloat, default: 0.4
Padding around the offsetbox.
- box_alignment(float, float)
A tuple of two floats for a vertical and horizontal alignment ofthe offset box w.r.t. theboxcoords.The lower-left corner is (0, 0) and upper-right corner is (1, 1).
- bboxpropsdict, optional
A dictionary of properties to set for the annotation bounding box,for exampleboxstyle andalpha. See
FancyBboxPatch
fordetails.- arrowprops: dict, optional
Arrow properties, see
Annotation
for description.- fontsize: float or str, optional
Translated to points and passed asmutation_scale into
FancyBboxPatch
to scale attributes of the box style (e.g. pador rounding_size). The name is chosen in analogy toText
wherefontsize defines the mutation scale as well. If not given,rcParams["legend.fontsize"]
(default:'medium'
) is used. SeeText.set_fontsize
for validvalues.- **kwargs
Other
AnnotationBbox
properties. SeeAnnotationBbox.set
fora list.
- offsetbox
- propertyanncoords#
- contains(mouseevent)[source]#
Test whether the artist contains the mouse event.
- Parameters:
- mouseevent
MouseEvent
- 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 theindividual 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:
- renderer
RendererBase
subclass.
- renderer
Notes
This method is overridden in the Artist subclasses.
- get_tightbbox(renderer=None)[source]#
Get the artist's bounding box in display space, taking clipping into account.
- Parameters:
- renderer
RendererBase
, optional Renderer used to draw the figure (i.e.
fig.canvas.get_renderer()
).
- renderer
- Returns:
Bbox
or NoneThe enclosing bounding box (in figure pixel coordinates), or Noneif clipping results in no intersection.
See also
Artist.get_window_extent
Get the artist bounding box, ignoring clipping.
- get_window_extent(renderer=None)[source]#
Get the artist's bounding box in display space, ignoring clipping.
The bounding box's width and height are non-negative.
Subclasses should override for inclusion in the bounding box "tight"calculation. Default is to return an empty bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.
To get accurate results you may need to manually call
savefig
ordraw_without_rendering
to haveMatplotlib compute the rendered size.- Parameters:
- renderer
RendererBase
, optional Renderer used to draw the figure (i.e.
fig.canvas.get_renderer()
).
- renderer
See also
Artist.get_tightbbox
Get the artist bounding box, taking clipping into account.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,annotation_clip=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,fontsize=<UNSET>,gid=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<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
a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array and two offsets from the bottom left corner of the image
float or None
bool
annotation_clip
bool or None
BboxBase
or Nonebool
Patch or (Path, Transform) or None
unknown
unknown
str
bool
object
bool
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
- set_fontsize(s=None)[source]#
Set the fontsize in points.
Ifs is not given, reset to
rcParams["legend.fontsize"]
(default:'medium'
).
- update_positions(renderer)[source]#
Update pixel positions for the annotated point, the text, and the arrow.
- propertyxyann#
- zorder=3#
- classmatplotlib.offsetbox.AuxTransformBox(aux_transform)[source]#
Bases:
OffsetBox
An OffsetBox with an auxiliary transform.
All child artists are first transformed withaux_transform, thentranslated with an offset (the same for all children) so the boundingbox of the children matches the drawn box. (In other words, adding anarbitrary translation toaux_transform has no effect as it will becancelled out by the later offsetting.)
AuxTransformBox
is similar toDrawingArea
, except that the extent ofthe box is not predetermined but calculated from the window extent of itschildren, and the extent of the children will be calculated in thetransformed coordinate.- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float)
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
unknown
str
bool
float
float
- classmatplotlib.offsetbox.DraggableAnnotation(annotation,use_blit=False)[source]#
Bases:
DraggableBase
- classmatplotlib.offsetbox.DraggableBase(ref_artist,use_blit=False)[source]#
Bases:
object
Helper base class for a draggable artist (legend, offsetbox).
Derived classes must override the following methods:
defsave_offset(self):''' Called when the object is picked for dragging; should save the reference position of the artist. '''defupdate_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:
deffinalize_offset(self):'''Called when the mouse is released.'''
In the current implementation of
DraggableLegend
andDraggableAnnotation
,update_offset
places the artists in displaycoordinates, andfinalize_offset
recalculates their position in axescoordinate and set a relevant attribute.- propertycanvas#
- propertycids#
- classmatplotlib.offsetbox.DraggableOffsetBox(ref_artist,offsetbox,use_blit=False)[source]#
Bases:
DraggableBase
- classmatplotlib.offsetbox.DrawingArea(width,height,xdescent=0.0,ydescent=0.0,clip=False)[source]#
Bases:
OffsetBox
The DrawingArea can contain any Artist as a child. The DrawingAreahas a fixed width and height. The position of children relative tothe parent is fixed. The children can be clipped at theboundaries of the parent.
- Parameters:
- width, heightfloat
Width and height of the container box.
- xdescent, ydescentfloat
Descent of the box in x- and y-direction.
- clipbool
Whether to clip the children to the box.
- propertyclip_children#
If the children of this DrawingArea should be clippedby DrawingArea bounding box.
- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float)
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
unknown
str
bool
float
float
- classmatplotlib.offsetbox.HPacker(pad=0.0,sep=0.0,width=None,height=None,align='baseline',mode='fixed',children=None)[source]#
Bases:
PackerBase
HPacker packs its children horizontally, automatically adjusting theirrelative positions at draw time.
+-------------------------------+| Child 1 Child 2 Child 3 |+-------------------------------+
- Parameters:
- padfloat, default: 0.0
The boundary padding in points.
- sepfloat, default: 0.0
The spacing between items in points.
- width, heightfloat, optional
Width and height of the container box in pixels, calculated ifNone.
- align{'top', 'bottom', 'left', 'right', 'center', 'baseline'}, default: 'baseline'
Alignment of boxes.
- mode{'fixed', 'expand', 'equal'}, default: 'fixed'
The packing mode.
'fixed' packs the given
Artist
s tight withsep spacing.'expand' uses the maximal available space to distribute theartists with equal spacing in between.
'equal': Each artist an equal fraction of the available spaceand is left-aligned (or top-aligned) therein.
- childrenlist of
Artist
The artists to pack.
Notes
pad andsep are in points and will be scaled with the rendererdpi, whilewidth andheight are in pixels.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float
- classmatplotlib.offsetbox.OffsetBox(**kwargs)[source]#
Bases:
Artist
A simple container artist.
The child artists are meant to be drawn at a relative position to itsparent.
Being an artist itself, all keyword arguments are passed on to
Artist
.- contains(mouseevent)[source]#
Delegate the mouse event contains-check to the children.
As a container, the
OffsetBox
does not respond itself tomouseevents.- Parameters:
- mouseevent
MouseEvent
- 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 theindividual Artist subclasses for details.
See also
- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- get_offset(bbox,renderer)[source]#
Return the offset as a tuple (x, y).
The extent parameters have to be provided to handle the case where theoffset is dynamically determined by a callable (see
set_offset
).- Parameters:
- bbox
Bbox
- renderer
RendererBase
subclass
- bbox
- get_window_extent(renderer=None)[source]#
Get the artist's bounding box in display space, ignoring clipping.
The bounding box's width and height are non-negative.
Subclasses should override for inclusion in the bounding box "tight"calculation. Default is to return an empty bounding box at 0, 0.
Warning
The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.
Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.
To get accurate results you may need to manually call
savefig
ordraw_without_rendering
to haveMatplotlib compute the rendered size.- Parameters:
- renderer
RendererBase
, optional Renderer used to draw the figure (i.e.
fig.canvas.get_renderer()
).
- renderer
See also
Artist.get_tightbbox
Get the artist bounding box, taking clipping into account.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float
- set_offset(xy)[source]#
Set the offset.
- Parameters:
- xy(float, float) or callable
The (x, y) coordinates of the offset in display units. These caneither be given explicitly as a tuple (x, y), or by providing afunction that converts the extent into the offset. This functionmust have the signature:
defoffset(width,height,xdescent,ydescent,renderer)->(float,float)
- classmatplotlib.offsetbox.OffsetImage(arr,*,zoom=1,cmap=None,norm=None,interpolation=None,origin=None,filternorm=True,filterrad=4.0,resample=False,dpi_cor=True,**kwargs)[source]#
Bases:
OffsetBox
- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,data=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zoom=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
unknown
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
unknown
float
- classmatplotlib.offsetbox.PackerBase(pad=0.0,sep=0.0,width=None,height=None,align='baseline',mode='fixed',children=None)[source]#
Bases:
OffsetBox
- Parameters:
- padfloat, default: 0.0
The boundary padding in points.
- sepfloat, default: 0.0
The spacing between items in points.
- width, heightfloat, optional
Width and height of the container box in pixels, calculated ifNone.
- align{'top', 'bottom', 'left', 'right', 'center', 'baseline'}, default: 'baseline'
Alignment of boxes.
- mode{'fixed', 'expand', 'equal'}, default: 'fixed'
The packing mode.
'fixed' packs the given
Artist
s tight withsep spacing.'expand' uses the maximal available space to distribute theartists with equal spacing in between.
'equal': Each artist an equal fraction of the available spaceand is left-aligned (or top-aligned) therein.
- childrenlist of
Artist
The artists to pack.
Notes
pad andsep are in points and will be scaled with the rendererdpi, whilewidth andheight are in pixels.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float
- classmatplotlib.offsetbox.PaddedBox(child,pad=0.0,*,draw_frame=False,patch_attrs=None)[source]#
Bases:
OffsetBox
A container to add a padding around an
Artist
.The
PaddedBox
contains aFancyBboxPatch
that is used to visualizeit when rendering.+----------------------------+| || || || <--pad--> Artist || ^ || pad || v |+----------------------------+
- Attributes:
- padfloat
The padding in points.
- patch
FancyBboxPatch
Whendraw_frame is True, this
FancyBboxPatch
is made visible andcreates a border around the box.
- Parameters:
- child
Artist
The contained
Artist
.- padfloat, default: 0.0
The padding in points. This will be scaled with the renderer dpi.In contrast,width andheight are inpixels and thus notscaled.
- draw_framebool
Whether to draw the contained
FancyBboxPatch
.- patch_attrsdict or None
Additional parameters passed to the contained
FancyBboxPatch
.
- child
- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float
- classmatplotlib.offsetbox.TextArea(s,*,textprops=None,multilinebaseline=False)[source]#
Bases:
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. Thewidth and height of the TextArea instance is the width and height of itschild text.
- Parameters:
- sstr
The text to be displayed.
- textpropsdict, default: {}
Dictionary of keyword parameters to be passed to the
Text
instance in the TextArea.- multilinebaselinebool, default: False
Whether the baseline for multiline text is adjusted so that itis (approximately) center-aligned with single-line text.
- draw(renderer)[source]#
Update the location of children if necessary and draw themto the givenrenderer.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,multilinebaseline=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,text=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
unknown
(float, float)
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
unknown
unknown
str
bool
float
float
- set_multilinebaseline(t)[source]#
Set multilinebaseline.
If True, the baseline for multiline text is adjusted so that it is(approximately) center-aligned with single-line text. This is usede.g. by the legend implementation so that single-line labels arebaseline-aligned, but multiline labels are "center"-aligned with them.
- classmatplotlib.offsetbox.VPacker(pad=0.0,sep=0.0,width=None,height=None,align='baseline',mode='fixed',children=None)[source]#
Bases:
PackerBase
VPacker packs its children vertically, automatically adjusting theirrelative positions at draw time.
+---------+| Child 1 || Child 2 || Child 3 |+---------+
- Parameters:
- padfloat, default: 0.0
The boundary padding in points.
- sepfloat, default: 0.0
The spacing between items in points.
- width, heightfloat, optional
Width and height of the container box in pixels, calculated ifNone.
- align{'top', 'bottom', 'left', 'right', 'center', 'baseline'}, default: 'baseline'
Alignment of boxes.
- mode{'fixed', 'expand', 'equal'}, default: 'fixed'
The packing mode.
'fixed' packs the given
Artist
s tight withsep spacing.'expand' uses the maximal available space to distribute theartists with equal spacing in between.
'equal': Each artist an equal fraction of the available spaceand is left-aligned (or top-aligned) therein.
- childrenlist of
Artist
The artists to pack.
Notes
pad andsep are in points and will be scaled with the rendererdpi, whilewidth andheight are in pixels.
- set(*,agg_filter=<UNSET>,alpha=<UNSET>,animated=<UNSET>,clip_box=<UNSET>,clip_on=<UNSET>,clip_path=<UNSET>,gid=<UNSET>,height=<UNSET>,in_layout=<UNSET>,label=<UNSET>,mouseover=<UNSET>,offset=<UNSET>,path_effects=<UNSET>,picker=<UNSET>,rasterized=<UNSET>,sketch_params=<UNSET>,snap=<UNSET>,transform=<UNSET>,url=<UNSET>,visible=<UNSET>,width=<UNSET>,zorder=<UNSET>)[source]#
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 and two offsets from the bottom left corner of the image
float or None
bool
BboxBase
or Nonebool
Patch or (Path, Transform) or None
str
float
bool
object
bool
(float, float) or callable
list of
AbstractPathEffect
None or bool or float or callable
bool
(scale: float, length: float, randomness: float)
bool or None
str
bool
float
float