Skip to content

Deemphasize numeric locations for legend() in docs. #13411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions lib/matplotlib/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,33 @@ def _update_bbox_to_anchor(self, loc_in_canvas):


_legend_kw_doc = '''
loc : int or string or pair of floats, default: :rc:`legend.loc` ('best' for \
axes, 'upper right' for figures)
The location of the legend. Possible codes are:
loc : str or pair of floats, default: :rc:`legend.loc` ('best' for axes, \
'upper right' for figures)
The location of the legend.

The strings
``'upper left', 'upper right', 'lower left', 'lower right'``
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that strings don't usually get double-backquoted in the docs, but I did so on purpose here as it seems better to add a bit of emphasis to the list of valid values. (The linebreaks are for the same reason.)

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
Expand All @@ -130,15 +154,6 @@ def _update_bbox_to_anchor(self, loc_in_canvas):
'center' 10
=============== =============


Alternatively can be a 2-tuple giving ``x, y`` of the lower-left
corner of the legend in axes coordinates (in which case
``bbox_to_anchor`` will be ignored).

The 'best' option can be quite slow for plots with large amounts
of data. Your plotting speed may benefit from providing a specific
location.

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
Expand Down