Other Parameters: | loc : str or pair of floats, default: rcParams["legend.loc"] = 'best' ('best' for axes, 'upper right' for figures)
The location of the legend.
The strings
'upper left', 'upper right', 'lower left', 'lower right'
place the legend at the corresponding corner of the axes/figure.
The strings
'upper center', 'lower center', 'center left', 'center right'
place the legend at the center of the corresponding edge of the
axes/figure.
The string 'center' places the legend at the center of the axes/figure.
The string 'best' places the legend at the location, among the nine
locations defined so far, with the minimum overlap with other drawn
artists. This option can be quite slow for plots with large amounts of
data; your plotting speed may benefit from providing a specific location.
The location can also be a 2-tuple giving the coordinates of the lower-left
corner of the legend in axes coordinates (in which case bbox_to_anchor
will be ignored).
For back-compatibility, 'center right' (but no other location) can also
be spelled 'right' , and each "string" locations can also be given as a
numeric value:
Location String |
Location Code |
'best' |
0 |
'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 |
bbox_to_anchor : BboxBase , 2-tuple, or 4-tuple of floats
Box that is used to position the legend in conjunction with loc.
Defaults to axes.bbox (if called as a method to Axes.legend ) or
figure.bbox (if Figure.legend ). This argument allows arbitrary
placement of the legend.
Bbox coordinates are interpreted in the coordinate system given by
bbox_transform , with the default transform
Axes or Figure coordinates, depending on which legend is called.
If a 4-tuple or BboxBase is given, then it specifies the bbox
(x, y, width, height) that the legend is placed in.
To put the legend in the best location in the bottom right
quadrant of the axes (or figure):
loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5)
A 2-tuple (x, y) places the corner of the legend specified by loc at
x, y. For example, to put the legend's upper right-hand corner in the
center of the axes (or figure) the following keywords can be used:
loc='upper right', bbox_to_anchor=(0.5, 0.5)
ncol : integer
The number of columns that the legend has. Default is 1.
prop : None or matplotlib.font_manager.FontProperties or dict
The font properties of the legend. If None (default), the current
matplotlib.rcParams will be used.
fontsize : int or float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
Controls the font size of the legend. If the value is numeric the
size will be the absolute font size in points. String values are
relative to the current default font size. This argument is only
used if prop is not specified.
numpoints : None or int
scatterpoints : None or int
scatteryoffsets : iterable of floats
The vertical offset (relative to the font size) for the markers
created for a scatter plot legend entry. 0.0 is at the base the
legend text, and 1.0 is at the top. To draw all markers at the
same height, set to [0.5] . Default is [0.375, 0.5, 0.3125] .
markerscale : None or int or float
markerfirst : bool
If True, legend marker is placed to the left of the legend label.
If False, legend marker is placed to the right of the legend
label.
Default is True.
frameon : None or bool
fancybox : None or bool
shadow : None or bool
framealpha : None or float
Control the alpha transparency of the legend's background.
Default is None , which will take the value from
rcParams["legend.framealpha"] = 0.8 . If shadow is activated and
framealpha is None , the default value is ignored.
facecolor : None or "inherit" or a color spec
edgecolor : None or "inherit" or a color spec
mode : {"expand", None}
If mode is set to "expand" the legend will be horizontally
expanded to fill the axes area (or bbox_to_anchor if defines
the legend's size).
bbox_transform : None or matplotlib.transforms.Transform
The transform for the bounding box (bbox_to_anchor ). For a value
of None (default) the Axes'
transAxes transform will be used.
title : str or None
The legend's title. Default is no title (None ).
title_fontsize: str or None
The fontsize of the legend's title. Default is the default fontsize.
borderpad : float or None
labelspacing : float or None
handlelength : float or None
handletextpad : float or None
borderaxespad : float or None
columnspacing : float or None
handler_map : dict or None
|