8000 Merge pull request #12206 from meeseeksmachine/auto-backport-of-pr-12… · matplotlib/matplotlib@aca51ff · GitHub
[go: up one dir, main page]

Skip to content

Commit aca51ff

Browse files
authored
Merge pull request #12206 from meeseeksmachine/auto-backport-of-pr-12186-on-v3.0.0-doc
Backport PR #12186 on branch v3.0.0-doc (DOC: fix API note about get_tightbbox)
2 parents b2ce254 + 3d9ee75 commit aca51ff

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

doc/api/api_changes.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,34 @@ which will improve the handling of log-axes. Note that the
6969
returned *image* now is of type `~.matplotlib.collections.QuadMesh`
7070
instead of `~.matplotlib.image.AxesImage`.
7171

72+
`.matplotlib.axes.Axes.get_tightbbox` now includes all artists
73+
--------------------------------------------------------------
74+
75+
For Matplotlib 3.0, *all* artists are now included in the bounding box
76+
returned by `.matplotlib.axes.Axes.get_tightbbox`.
77+
78+
`.matplotlib.axes.Axes.get_tightbbox` adds a new kwarg ``bbox_extra_artists``
79+
to manually specify the list of artists on the axes to include in the
80+
tight bounding box calculation.
81+
82+
Layout tools like `.Figure.tight_layout`, ``constrained_layout``,
83+
and ``fig.savefig('fname.png', bbox_inches="tight")`` use
84+
`.matplotlib.axes.Axes.get_tightbbox` to determine the bounds of each axes on
85+
a figure and adjust spacing between axes.
86+
87+
In Matplotlib 2.2 ``get_tightbbox`` started to include legends made on the
88+
axes, but still excluded some other artists, like text that may overspill an
89+
axes. This has been expanded to include *all* artists.
90+
91+
This new default may be overridden in either of three ways:
92+
93+
1. Make the artist to be excluded a child of the figure, not the axes. E.g.,
94+
call ``fig.legend()`` instead of ``ax.legend()`` (perhaps using
95+
`~.matplotlib.axes.Axes.get_legend_handles_labels` to gather handles and
96+
labels from the parent axes).
97+
2. If the artist is a child of the axes, set the artist property
98+
``artist.set_in_layout(False)``.
99+
3. Manually specify a list of artists in the new kwarg ``bbox_extra_artists``.
72100

73101
`.matplotlib.Axes.get_tightbbox` now includes all artists
74102
---------------------------------------------------------

0 commit comments

Comments
 (0)
0