mpl_toolkits.axes_grid1.anchored_artists
¶mpl_toolkits.axes_grid1.anchored_artists.
AnchoredDrawingArea
(width, height, xdescent, ydescent, loc, pad=0.4, borderpad=0.5, prop=None, frameon=True, **kwargs)¶Bases: matplotlib.offsetbox.AnchoredOffsetbox
An anchored container with a fixed size and fillable DrawingArea.
Artists added to the drawing_area will have their coordinates interpreted as pixels. Any transformations set on the artists will be overridden.
Parameters: | width, height : int or float
xdescent, ydescent : int or float
loc : int
pad : int or float, optional
borderpad : int or float, optional
prop :
frameon : bool, optional
**kwargs :
|
---|
Examples
To display blue and red circles of different sizes in the upper right of an axes ax:
>>> ada = AnchoredDrawingArea(20, 20, 0, 0, loc=1, frameon=False)
>>> ada.drawing_area.add_artist(Circle((10, 10), 10, fc="b"))
>>> ada.drawing_area.add_artist(Circle((30, 10), 5, fc="r"))
>>> ax.add_artist(ada)
Attributes
drawing_area | (matplotlib.offsetbox.DrawingArea ) A container for artists to display. |
mpl_toolkits.axes_grid1.anchored_artists.
AnchoredAuxTransformBox
(transform, loc, pad=0.4, borderpad=0.5, prop=None, frameon=True, **kwargs)¶Bases: matplotlib.offsetbox.AnchoredOffsetbox
An anchored container with transformed coordinates.
Artists added to the drawing_area are scaled according to the coordinates of the transformation used. The dimensions of this artist will scale to contain the artists added.
Parameters: | transform :
loc : int
pad : int or float, optional
borderpad : int or float, optional
prop :
frameon : bool, optional
**kwargs :
|
---|
Examples
To display an ellipse in the upper left, with a width of 0.1 and height of 0.4 in data coordinates:
>>> box = AnchoredAuxTransformBox(ax.transData, loc=2)
>>> el = Ellipse((0,0), width=0.1, height=0.4, angle=30)
>>> box.drawing_area.add_artist(el)
>>> ax.add_artist(box)
Attributes
drawing_area | (matplotlib.offsetbox.AuxTransformBox ) A container for artists to display. |
mpl_toolkits.axes_grid1.anchored_artists.
AnchoredEllipse
(transform, width, height, angle, loc, pad=0.1, borderpad=0.1, prop=None, frameon=True, **kwargs)¶Bases: matplotlib.offsetbox.AnchoredOffsetbox
Draw an anchored ellipse of a given size.
Parameters: | transform :
width, height : int or float
angle : int or float
loc : int
pad : int or float, optional
borderpad : int or float, optional
frameon : bool, optional
prop :
**kwargs :
|
---|
Attributes
ellipse | (matplotlib.patches.Ellipse ) Ellipse patch drawn. |
mpl_toolkits.axes_grid1.anchored_artists.
AnchoredSizeBar
(transform, size, label, loc, pad=0.1, borderpad=0.1, sep=2, frameon=True, size_vertical=0, color='black', label_top=False, fontproperties=None, **kwargs)¶Bases: matplotlib.offsetbox.AnchoredOffsetbox
Draw a horizontal scale bar with a center-aligned label underneath.
Parameters: | transform :
size : int or float
label : str
loc : int
pad : int or float, optional
borderpad : int or float, optional
sep : int or float, optional
frameon : bool, optional
size_vertical : int or float, optional
color : str, optional
label_top : bool, optional
fontproperties :
**kwargs :
|
---|
Notes
If prop is passed as a keyworded argument, but fontproperties is not, then prop is be assumed to be the intended fontproperties. Using both prop and fontproperties is not supported.
Examples
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar
>>> fig, ax = plt.subplots()
>>> ax.imshow(np.random.random((10,10)))
>>> bar = AnchoredSizeBar(ax.transData, 3, '3 data units', 4)
>>> ax.add_artist(bar)
>>> fig.show()
Using all the optional parameters
>>> import matplotlib.font_manager as fm
>>> fontprops = fm.FontProperties(size=14, family='monospace')
>>> bar = AnchoredSizeBar(ax.transData, 3, '3 units', 4, pad=0.5, sep=5, borderpad=0.5, frameon=False, size_vertical=0.5, color='white', fontproperties=fontprops)
Attributes
size_bar | (matplotlib.offsetbox.AuxTransformBox ) Container for the size bar. |
txt_label | (matplotlib.offsetbox.TextArea ) Container for the label of the size bar. |