
matplotlib.offsetbox¶The OffsetBox is a simple container artist. The child artist are meantto be drawn at a relative position to its parent. The [VH]Packer,DrawingArea and TextArea are derived from the OffsetBox.
The [VH]Packer automatically adjust the relative postisions of theirchildren, which should be instances of the OffsetBox. This is used toalign similar artists together, e.g., in legend.
The DrawingArea can contain any Artist as a child. TheDrawingArea has a fixed width and height. The position of childrenrelative to the parent is fixed. The TextArea is contains a singleText instance. The width and height of the TextArea instance is thewidth and height of the its child text.
matplotlib.offsetbox.AnchoredOffsetbox(loc,pad=0.4,borderpad=0.5,child=None,prop=None,frameon=True,bbox_to_anchor=None,bbox_transform=None,**kwargs)¶Bases:matplotlib.offsetbox.OffsetBox
An offset box placed according to the legend locationloc. AnchoredOffsetbox has a single child. When multiple childrenis needed, use other OffsetBox class to enclose them. By default,the offset box is anchored against its parent axes. You mayexplicitly specify the bbox_to_anchor.
loc is a string or an integer specifying the legend location.The valid location codes are:
'upper right':1,'upper left':2,'lower left':3,'lower right':4,'right':5,'center left':6,'center right':7,'lower center':8,'upper center':9,'center':10,
borderpad : pad between offsetbox frame and the bbox_to_anchor,
child : OffsetBox instance that will be anchored.
prop : font property. This is only used as a reference for paddings.
frameon : draw a frame box if True.
bbox_to_anchor : bbox to anchor. Use self.axes.bbox if None.
bbox_transform : with which the bbox_to_anchor will be transformed.
draw(renderer)¶draw the artist
get_bbox_to_anchor()¶return the bbox that the legend will be anchored
get_child()¶return the child
get_children()¶return the list of children
get_extent(renderer)¶return the extent of the artist. The extent of the childadded with the pad is returned
get_window_extent(renderer)¶get the bounding box in display space.
set_bbox_to_anchor(bbox,transform=None)¶set the bbox that the child will be anchored.
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.
set_child(child)¶set the child to be anchored
update_frame(bbox,fontsize=None)¶zorder = 5¶matplotlib.offsetbox.AnchoredText(s,loc,pad=0.4,borderpad=0.5,prop=None,**kwargs)¶Bases:matplotlib.offsetbox.AnchoredOffsetbox
AnchoredOffsetbox with Text.
| Parameters: | s : string
loc : str
pad : float, optional
borderpad : float, optional
prop :
|
|---|
Notes
Other keyword parameters ofAnchoredOffsetbox are alsoallowed.
matplotlib.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)¶Bases:matplotlib.artist.Artist,matplotlib.text._AnnotationBase
Annotation-like class, but with offsetbox instead of Text.
offsetbox : OffsetBox instance
other parameters are identical to that of Annotation.
anncoords¶contains(event)¶draw(renderer)¶Draw theAnnotation object to the givenrenderer.
get_children()¶get_fontsize(s=None)¶return fontsize in points
set_figure(fig)¶set_fontsize(s=None)¶set fontsize in points
update_positions(renderer)¶Update the pixel positions of the annotated point and the text.
xyann¶zorder = 3¶matplotlib.offsetbox.AuxTransformBox(aux_transform)¶Bases:matplotlib.offsetbox.OffsetBox
Offset Box with the aux_transform . Its children will betransformed with the aux_transform first then will beoffseted. The absolute coordinate of the aux_transform is meaningas it will be automatically adjust so that the left-lower cornerof the bounding box of children will be set to (0,0) before theoffset transform.
It is similar to drawing area, except that the extent of the boxis not predetermined but calculated from the window extent of itschildren. Furthermore, the extent of the children will becalculated in the transformed coordinate.
add_artist(a)¶Add anyArtist to the container box
draw(renderer)¶Draw the children
get_extent(renderer)¶get_offset()¶return offset of the container.
get_window_extent(renderer)¶get the bounding box in display space.
set_offset(xy)¶set offset of the container.
Accept : tuple of x,y coordinate in disokay units.
set_transform(t)¶set_transform is ignored.
matplotlib.offsetbox.DraggableAnnotation(annotation,use_blit=False)¶Bases:matplotlib.offsetbox.DraggableBase
save_offset()¶update_offset(dx,dy)¶matplotlib.offsetbox.DraggableBase(ref_artist,use_blit=False)¶Bases:object
helper code for a draggable artist (legend, offsetbox)The derived class must override following two method.
- def saveoffset(self):
- pass
- def update_offset(self, dx, dy):
- pass
saveoffset is called when the object is picked for dragging and it ismeant to save reference position of the artist.
Optionally you may override following two methods.
- def artist_picker(self, artist, evt):
- return self.ref_artist.contains(evt)
- def finalize_offset(self):
- pass
artist_picker(artist,evt)¶disconnect()¶disconnect the callbacks
finalize_offset()¶on_motion(evt)¶on_motion_blit(evt)¶on_pick(evt)¶on_release(event)¶save_offset()¶update_offset(dx,dy)¶matplotlib.offsetbox.DraggableOffsetBox(ref_artist,offsetbox,use_blit=False)¶Bases:matplotlib.offsetbox.DraggableBase
get_loc_in_canvas()¶save_offset()¶update_offset(dx,dy)¶matplotlib.offsetbox.DrawingArea(width,height,xdescent=0.0,ydescent=0.0,clip=False)¶Bases:matplotlib.offsetbox.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.
width,height : width and height of the container box.xdescent,ydescent : descent of the box in x- and y-direction.clip : Whether to clip the children
add_artist(a)¶Add anyArtist to the container box
clip_children¶If the children of this DrawingArea should be clippedby DrawingArea bounding box.
draw(renderer)¶Draw the children
get_extent(renderer)¶Return with, height, xdescent, ydescent of box
get_offset()¶return offset of the container.
get_window_extent(renderer)¶get the bounding box in display space.
set_offset(xy)¶set offset of the container.
Accept : tuple of x,y cooridnate in disokay units.
set_transform(t)¶set_transform is ignored.
matplotlib.offsetbox.HPacker(pad=None,sep=None,width=None,height=None,align='baseline',mode='fixed',children=None)¶Bases:matplotlib.offsetbox.PackerBase
The HPacker has its children packed horizontally. It automaticallyadjusts the relative positions of children at draw time.
| Parameters: | pad : float, optional
sep : float, optional
width : float, optional height : float, optional
align : str
mode : str
|
|---|
Notes
pad andsep need to given in points and will be scale withthe renderer dpi, whilewidth andheight need to be inpixels.
get_extent_offsets(renderer)¶update offset of children and return the extents of the box
matplotlib.offsetbox.OffsetBox(*args,**kwargs)¶Bases:matplotlib.artist.Artist
The OffsetBox is a simple container artist. The child artist are meantto be drawn at a relative position to its parent.
contains(mouseevent)¶draw(renderer)¶Update the location of children if necessary and draw themto the givenrenderer.
get_children()¶Return a list of artists it contains.
get_extent(renderer)¶Return with, height, xdescent, ydescent of box
get_extent_offsets(renderer)¶get_offset(width,height,xdescent,ydescent,renderer)¶Get the offset
accepts extent of the box
get_visible_children()¶Return a list of visible artists it contains.
get_window_extent(renderer)¶get the bounding box in display space.
set_height(height)¶Set the height
accepts float
set_offset(xy)¶Set the offset
accepts x, y, tuple, or a callable object.
set_width(width)¶Set the width
accepts float
matplotlib.offsetbox.OffsetImage(arr,zoom=1,cmap=None,norm=None,interpolation=None,origin=None,filternorm=1,filterrad=4.0,resample=False,dpi_cor=True,**kwargs)¶Bases:matplotlib.offsetbox.OffsetBox
draw(renderer)¶Draw the children
get_children()¶get_data()¶get_extent(renderer)¶get_offset()¶return offset of the container.
get_window_extent(renderer)¶get the bounding box in display space.
get_zoom()¶set_data(arr)¶set_zoom(zoom)¶matplotlib.offsetbox.PackerBase(pad=None,sep=None,width=None,height=None,align=None,mode=None,children=None)¶Bases:matplotlib.offsetbox.OffsetBox
| Parameters: | pad : float, optional
sep : float, optional
width : float, optional height : float, optional
align : str, optional
mode : str, optional
|
|---|
Notes
pad andsep need to given in points and will be scale withthe renderer dpi, whilewidth andheight need to be inpixels.
matplotlib.offsetbox.PaddedBox(child,pad=None,draw_frame=False,patch_attrs=None)¶Bases:matplotlib.offsetbox.OffsetBox
pad : boundary pad
Note
pad need to given in points and will bescale with the renderer dpi, whilewidth andheightneed to be in pixels.
draw(renderer)¶Update the location of children if necessary and draw themto the givenrenderer.
draw_frame(renderer)¶get_extent_offsets(renderer)¶update offset of childrens and return the extents of the box
update_frame(bbox,fontsize=None)¶matplotlib.offsetbox.TextArea(s,textprops=None,multilinebaseline=None,minimumdescent=True)¶Bases:matplotlib.offsetbox.OffsetBox
The TextArea is contains a single Text instance. The text isplaced at (0,0) with baseline+left alignment. The width and heightof the TextArea instance is the width and height of the its childtext.
| Parameters: | s : str
textprops : multilinebaseline : bool, optional
minimumdescent : bool, optional
|
|---|
draw(renderer)¶Draw the children
get_extent(renderer)¶get_minimumdescent()¶get minimumdescent.
get_multilinebaseline()¶get multilinebaseline .
get_offset()¶return offset of the container.
get_text()¶Returns the string representation of this area’s text
get_window_extent(renderer)¶get the bounding box in display space.
set_minimumdescent(t)¶Set minimumdescent .
If True, extent of the single line text is adjusted so thatit has minimum descent of “p”
set_multilinebaseline(t)¶Set multilinebaseline .
If True, baseline for multiline text isadjusted so that it is (approximatedly) center-aligned withsingleline text.
set_offset(xy)¶set offset of the container.
Accept : tuple of x,y coordinates in display units.
set_text(s)¶Set the text of this area as a string.
set_transform(t)¶set_transform is ignored.
matplotlib.offsetbox.VPacker(pad=None,sep=None,width=None,height=None,align='baseline',mode='fixed',children=None)¶Bases:matplotlib.offsetbox.PackerBase
The VPacker has its children packed vertically. It automaticallyadjust the relative positions of children in the drawing time.
| Parameters: | pad : float, optional
sep : float, optional
width : float, optional height : float, optional
align : str, optional
mode : str, optional
|
|---|
Notes
pad andsep need to given in points and will be scale withthe renderer dpi, whilewidth andheight need to be inpixels.
get_extent_offsets(renderer)¶update offset of childrens and return the extents of the box
matplotlib.offsetbox.bbox_artist(*args,**kwargs)¶