8000 DOC: fix API note about get_tightbbox · matplotlib/matplotlib@077a1c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 077a1c9

Browse files
committed
DOC: fix API note about get_tightbbox
1 parent f3b97dd commit 077a1c9

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
@@ -59,6 +59,34 @@ which will improve the handling of log-axes. Note that the
5959
returned *image* now is of type `~.matplotlib.collections.QuadMesh`
6060
instead of `~.matplotlib.image.AxesImage`.
6161

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

6391
`Text.set_text` with string argument ``None`` sets string to empty
6492
------------------------------------------------------------------

0 commit comments

Comments
 (0)
0