-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC: nudges legend position in tutorial to be within graph area #12377
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
DOC: nudges legend position in tutorial to be within graph area #12377
Conversation
I think, at least the first part is intended to demonstrate that cropping may happen:
However, I don't follow the overall argument of that section. @jklymak Why would I want to take the legend out of the layout? Clipping is always undesirable. If I want the legend not to steal space from the subplot layout, I should place it in a way that it's within the subplot grid. IMO that's what should be demonstrated here (e.g. something like |
This section is intended to show how to opt out of the contrained-layout mechanism for a legend. This is desireable in any case where you don't want your grid layout be affected by the legend. One reason for that is given in the text,
The two options described here are (1) use The confusion may be due to the second example not having the If you put the legend into the axes as proposed here, there would not be any need to opt out of constrained-layout at all. |
Thanks for the PR @deniederhut However, as noted above, the point of the example is that the legend is off the edge of the plot and cropped. If the pre-amble is not clear on this point, please let us know! |
Can we add a positive example of when/why to exclude the legend from the layout? So far we're only explaining that there is some danger in doing so because it can clip the legend. |
No, there is no danger, or at least there shouldn't be any. The problem is, just looking at the pictures the wrong expectation is created. The picture that is shown is the desired and expected. Reading the text, I find this pretty understandable. The point would be crystal clear if the figure saved by But... The code does not seem to be runnable and does not give a sensible result. I used this code
i.e. the code from the matplotlib 3.0 documentation with Assuming that what is meant here is Using the second code (the one with In my eyes there are the following things to do:
|
Agreed, opened new issue... |
PR Summary
The tutorial on constrained layout has an example showing the (recommended) approach of placing a legend on the figure object to avoid shrinking a bunch of other stuff. However, the legend runs off the edge of the plot figure, which seems a bit undesirable. This commit bumps the anchor point a bit so everything fits.
Before
After
PR Checklist