mpl.legend¶
The legend module defines the Legend class, which is responsible for drawing legends associated with axes and/or figures.
Important
It is unlikely that you would ever create a Legend instance manually.
Most users would normally create a legend via the
legend() function. For more details on legends
there is also a legend guide.
The Legend class can be considered as a container of legend handles
and legend texts. Creation of corresponding legend handles from the
plot elements in the axes or figures (e.g., lines, patches, etc.) are
specified by the handler map, which defines the mapping between the
plot elements and the legend handlers to be used (the default legend
handlers are defined in the legend_handler module).
Note that not all kinds of artist are supported by the legend yet by default
but it is possible to extend the legend handler’s capabilities to
support arbitrary objects. See the legend guide
for more information.
Functions¶
allow_rasterization(draw) |
Decorator for Artist.draw method. |
is_string_like(obj) |
Return True if obj looks like a string |
iterable(obj) |
return true if obj is iterable |
safezip(*args) |
make sure args are equal len before zipping |
Classes¶
Artist() |
Abstract base class for someone who renders into a FigureCanvas. |
BarContainer(patches[, errorbar]) |
|
Bbox(points, **kwargs) |
A mutable bounding box. |
BboxBase([shorthand_name]) |
This is the base class of all bounding boxes, and provides read-only access to its data. |
BboxTransformFrom(boxin, **kwargs) |
BboxTransformFrom linearly transforms points from a given |
BboxTransformTo(boxout, **kwargs) |
BboxTransformTo is a transformation that linearly |
CircleCollection(sizes, **kwargs) |
A collection of circles, drawn using splines. |
DraggableLegend(legend[, use_blit, update]) |
|
DraggableOffsetBox(ref_artist, offsetbox[, ...]) |
|
DrawingArea(width, height[, xdescent, ...]) |
The DrawingArea can contain any Artist as a child. |
ErrorbarContainer(lines[, has_xerr, has_yerr]) |
|
FancyBboxPatch(xy, width, height[, ...]) |
Draw a fancy box around a rectangle with lower left at xy*=(*x, y) with specified width and height. |
FontProperties([family, style, variant, ...]) |
A class for storing and manipulating font properties. |
HPacker([pad, sep, width, height, align, ...]) |
The HPacker has its children packed horizontally. |
Legend(parent, handles, labels[, loc, ...]) |
Place a legend on the axes at location loc. |
Line2D(xdata, ydata[, linewidth, linestyle, ...]) |
A line - the line can have both a solid linestyle connecting all the vertices, and a marker at each vertex. |
LineCollection(segments[, linewidths, ...]) |
All parameters must be sequences or scalars; if scalars, they will be converted to sequences. |
Patch([edgecolor, facecolor, color, ...]) |
A patch is a 2D artist with a face color and an edge color. |
PathCollection(paths[, sizes]) |
This is the most basic Collection subclass. |
PolyCollection(verts[, sizes, closed]) |
|
Rectangle(xy, width, height[, angle]) |
Draw a rectangle with lower left at xy = (x, y) with specified width and height. |
RegularPolyCollection(numsides[, rotation, ...]) |
Draw a collection of regular polygons with numsides. |
Shadow(patch, ox, oy[, props]) |
|
StemContainer(markerline_stemlines_baseline, ...) |
|
TextArea(s[, textprops, multilinebaseline, ...]) |
The TextArea is contains a single Text instance. |
TransformedBbox(bbox, transform, **kwargs) |
A Bbox that is automatically transformed by a given transform. |
VPacker([pad, sep, width, height, align, ...]) |
The VPacker has its children packed vertically. |
silent_list(type[, seq]) |
override repr when returning a list of matplotlib artists to |
xrange |
xrange(start, stop[, step]) -> xrange object |