-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
SubFigure
legend not included in figure bounding box
#20736
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
Comments
I think the Figure's extra artists should only be the SubFigures, and anything added at the Figure level. I don't think things at the SubFigure level should bubble up to the Figure level. OTOH there are issues here that will require some thought. Folks enjoy adding legends outside the figure, and then letting bbox_inches='tight' expand the figure to match. Its hard to know how that will be compatible with SubFigure. |
Yes in fact this is exactly how I ran into this problem. I wanted to add a legend outside the axes of the subfigure. I've removed my suggestion from the issue, because there are problems with that too (what if there was a figure legend or other figure artists not associated with subfigures for example) |
Yeah, that is my main point - Figure and SubFigure should be different from one another (probably). |
I had a quick investigation and ignoring the fact that matplotlib/lib/matplotlib/figure.py Lines 1642 to 1646 in d2a9710
such that |
Bug report
Bug summary
This relies on #20723 being addressed.
As reported in a comment on that issue, a legend added to a
SubFigure
is not included when calculating the bbox of the parent figure and so the subfigure legendis cut off the plot when saving a figure withbbox_inches="tight"
.Code for reproduction
Actual outcome
Expected outcome
The subfigure legend should be included in the bbox.
Matplotlib version
import matplotlib; print(matplotlib.__version__)
): 3.4.2print(matplotlib.get_backend())
): TkAggThe text was updated successfully, but these errors were encountered: