mpl.offsetbox.AnchoredOffsetbox

class mpl.offsetbox.AnchoredOffsetbox(loc, pad=0.4, borderpad=0.5, child=None, prop=None, frameon=True, bbox_to_anchor=None, bbox_transform=None, **kwargs)[source]

An offset box placed according to the legend location loc. AnchoredOffsetbox has a single child. When multiple children is needed, use other OffsetBox class to enclose them. By default, the offset box is anchored against its parent axes. You may explicitly specify the bbox_to_anchor.

__init__(loc, pad=0.4, borderpad=0.5, child=None, prop=None, frameon=True, bbox_to_anchor=None, bbox_transform=None, **kwargs)[source]

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,
pad : pad around the child for drawing a frame. given in
fraction of fontsize.

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.

Methods

__init__(loc[, pad, borderpad, child, prop, ...]) loc is a string or an integer specifying the legend location.
add_callback(func) Adds a callback function that will be called whenever one of the Artist‘s properties changes.
contains(mouseevent)
convert_xunits(x) For artists in an axes, if the xaxis has units support,
convert_yunits(y) For artists in an axes, if the yaxis has units support,
draw(renderer) draw the artist
findobj([match, include_self]) Find artist objects.
format_cursor_data(data) Return cursor data string formatted.
get_agg_filter() return filter function to be used for agg filter
get_alpha() Return the alpha value used for blending - not supported on all
get_animated() Return the artist’s animated state
get_axes() Return the Axes instance the artist resides in, or None.
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_clip_box() Return artist clipbox
get_clip_on() Return whether artist uses clipping
get_clip_path() Return artist clip path
get_contains() Return the _contains test used by the artist, or None for default.
get_cursor_data(event) Get the cursor data for a given event.
get_extent(renderer) return the extent of the artist. The extent of the child
get_extent_offsets(renderer)
get_figure() Return the Figure instance the artist belongs to.
get_gid() Returns the group id
get_label() Get the label used for this artist in the legend.
get_offset(width, height, xdescent, ...) Get the offset
get_path_effects()
get_picker() Return the picker object used by this artist
get_rasterized() return True if the artist is to be rasterized
get_sketch_params() Returns the sketch parameters for the artist.
get_snap() Returns the snap setting which may be:
get_transform() Return the Transform instance used by this artist.
get_transformed_clip_path_and_affine() Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation.
get_url() Returns the url
get_visible() Return the artist’s visiblity
get_visible_children() Return a list of visible artists it contains.
get_window_extent(renderer) get the bounding box in display space.
get_zorder() Return the Artist‘s zorder.
have_units() Return True if units are set on the x or y axes
hitlist(event) List the children of the artist which contain the mouse event event.
is_figure_set() Returns True if the artist is assigned to a Figure.
is_transform_set() Returns True if Artist has a transform explicitly set.
pchanged() Fire an event when property changed, calling all of the registered callbacks.
pick(mouseevent) call signature:
pickable() Return True if Artist is pickable.
properties() return a dictionary mapping property name -> value for all Artist props
remove() Remove the artist from the figure if possible.
remove_callback(oid) Remove a callback based on its id.
set(**kwargs) A property batch setter.
set_agg_filter(filter_func) set agg_filter fuction.
set_alpha(alpha) Set the alpha value used for blending - not supported on all backends.
set_animated(b) Set the artist’s animation state.
set_axes(axes) Set the Axes instance in which the artist resides, if any.
set_bbox_to_anchor(bbox[, transform]) set the bbox that the child will be anchored.
set_child(child) set the child to be anchored
set_clip_box(clipbox) Set the artist’s clip Bbox.
set_clip_on(b) Set whether artist uses clipping.
set_clip_path(path[, transform]) Set the artist’s clip path, which may be:
set_contains(picker) Replace the contains test used by this artist.
set_figure(fig) Set the figure
set_gid(gid) Sets the (group) id for the artist
set_height(height) Set the height
set_label(s) Set the label to s for auto legend.
set_offset(xy) Set the offset
set_path_effects(path_effects) set path_effects, which should be a list of instances of
set_picker(picker) Set the epsilon for picking used by this artist
set_rasterized(rasterized) Force rasterized (bitmap) drawing in vector backend output.
set_sketch_params([scale, length, randomness]) Sets the sketch parameters.
set_snap(snap) Sets the snap setting which may be:
set_transform(t) Set the Transform instance used by this artist.
set_url(url) Sets the url for the artist
set_visible(b) Set the artist’s visiblity.
set_width(width) Set the width
set_zorder(level) Set the zorder for the artist.
update(props) Update the properties of this Artist from the dictionary prop.
update_frame(bbox[, fontsize])
update_from(other) Copy properties from other to self.

Attributes

aname
axes The Axes instance the artist resides in, or None.
mouseover
stale If the artist is ‘stale’ and needs to be re-drawn for the output to match the internal state of the artist.
zorder