legend_wrapper¶
-
legend_wrapper
(self, handles=None, labels=None, ncol=None, ncols=None, center=None, order='C', loc=None, label=None, title=None, fontsize=None, fontweight=None, fontcolor=None, color=None, marker=None, lw=None, linewidth=None, dashes=None, linestyle=None, markersize=None, frameon=None, frame=None, **kwargs)[source]¶ Wraps
Axes
legend
andFigure
legend
, adds some handy features.- Parameters
handles (list of
Artist
, optional) – List of artists instances, or list of lists of artist instances (see thecenter
keyword). IfNone
, the artists are retrieved withget_legend_handles_labels
.labels (list of str, optional) – Matching list of string labels, or list of lists of string labels (see the
center
keywod). IfNone
, the labels are retrieved by callingget_label
on eachArtist
inhandles
.ncol, ncols (int, optional) – The number of columns.
ncols
is an alias, added for consistency withsubplots
.order ({‘C’, ‘F’}, optional) – Whether legend handles are drawn in row-major (
'C'
) or column-major ('F'
) order. Analagous tonumpy.array
ordering. For some reason'F'
was the original matplotlib default. Default is'C'
.center (bool, optional) – Whether to center each legend row individually. If
True
, we actually draw successive single-row legends stacked on top of each other.If
None
, we infer this setting fromhandles
. Default isTrue
ifhandles
is a list of lists; each sublist is used as a row in the legend. Otherwise, default isFalse
.loc (int or str, optional) – The legend location. The following location keys are valid:
Location
Valid keys
“best” possible
0
,'best'
,'b'
,'i'
,'inset'
upper right
1
,'upper right'
,'ur'
upper left
2
,'upper left'
,'ul'
lower left
3
,'lower left'
,'ll'
lower right
4
,'lower right'
,'lr'
center left
5
,'center left'
,'cl'
center right
6
,'center right'
,'cr'
lower center
7
,'lower center'
,'lc'
upper center
8
,'upper center'
,'uc'
center
9
,'center'
,'c'
label, title (str, optional) – The legend title. The
label
keyword is also accepted, for consistency withcolorbar
.fontsize, fontweight, fontcolor (optional) – The font size, weight, and color for legend text.
color, lw, linewidth, marker, linestyle, dashes, markersize (property-spec, optional) – Properties used to override the legend handles. For example, if you want a legend that describes variations in line style ignoring variations in color, you might want to use
color='k'
. For now this does not includefacecolor
,edgecolor
, andalpha
, becauselegend
uses these keyword args to modify the frame properties.
- Other Parameters
**kwargs – Passed to
legend
.