SubFigure legend not included in figure bounding box
#20736
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
SubFigureis 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: