Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5639790

Browse files
anntzerImportanceOfBeingErnest
authored andcommitted
Deemphasize numeric locations for legend() in docs. (#13411)
... as well as the "right" synonym to "center right". (Note that despite the mention of backcompat, I am not proposing a deprecation here.)
1 parent daaf978 commit 5639790

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

lib/matplotlib/legend.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,33 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
110110

111111

112112
_legend_kw_doc = '''
113-
loc : int or string or pair of floats, default: :rc:`legend.loc` ('best' for \
114-
axes, 'upper right' for figures)
115-
The location of the legend. Possible codes are:
113+
loc : str or pair of floats, default: :rc:`legend.loc` ('best' for axes, \
114+
'upper right' for figures)
115+
The location of the legend.
116+
117+
The strings
118+
``'upper left', 'upper right', 'lower left', 'lower right'``
119+
place the legend at the corresponding corner of the axes/figure.
120+
121+
The strings
122+
``'upper center', 'lower center', 'center left', 'center right'``
123+
place the legend at the center of the corresponding edge of the
124+
axes/figure.
125+
126+
The string ``'center'`` places the legend at the center of the axes/figure.
127+
128+
The string ``'best'`` places the legend at the location, among the nine
129+
locations defined so far, with the minimum overlap with other drawn
130+
artists. This option can be quite slow for plots with large amounts of
131+
data; your plotting speed may benefit from providing a specific location.
132+
133+
The location can also be a 2-tuple giving the coordinates of the lower-left
134+
corner of the legend in axes coordinates (in which case *bbox_to_anchor*
135+
will be ignored).
136+
137+
For back-compatibility, ``'center right'`` (but no other location) can also
138+
be spelled ``'right'``, and each "string" locations can also be given as a
139+
numeric value:
116140
117141
=============== =============
118142
Location String Location Code
@@ -130,15 +154,6 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
130154
'center' 10
131155
=============== =============
132156
133-
134-
Alternatively can be a 2-tuple giving ``x, y`` of the lower-left
135-
corner of the legend in axes coordinates (in which case
136-
``bbox_to_anchor`` will be ignored).
137-
138-
The 'best' option can be quite slow for plots with large amounts
139-
of data. Your plotting speed may benefit from providing a specific
140-
location.
141-
142157
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
143158
Box that is used to position the legend in conjunction with *loc*.
144159
Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or

0 commit comments

Comments
 (0)