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

Skip to content

Conversation

ndevenish
Copy link
Contributor

The documentation states that the default legend position is 0, which would position it at the "best" place. I've actually believed this and assumed that legend positioning was broken before (if the default is "best", then why bother setting it manually?), but after digging found that this is not the case.

The actual default is controlled at
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/legend.py#L315
which takes the None default and pulls the rcParam["legend.loc"] which defaults to "upper right". The defaults code actually mentions at
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/rcsetup.py#L663
that it should be changed at some point, but I don't know the reasoning for that so the documentation fix seemed the easiest way.

This literally just changes the docstring to match the current behavior; an alternate patch would be to actually change the default to reflect the documentation.

The documentation stated that the default legend position was 0, corresponding
to "best". This does not match the behavior of the current code, which
uses as default the rcParam value "legend.loc", which at time of writing
defaults to "upper-right".
@efiring
Copy link
Member

efiring commented Apr 20, 2015

I've tripped over this myself.
It raises a larger point: I think that ideally, each docstring should include the correspondence between defaults and rcParams keys.

WeatherGod added a commit that referenced this pull request Apr 20, 2015
Change documentation of legend to reflect default upper-right
@WeatherGod WeatherGod merged commit 8f9bc7b into matplotlib:master Apr 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants