8000 Deprecate the renderer parameter to Figure.tight_layout. · matplotlib/matplotlib@1b7454d · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b7454d

Browse files
committed
Deprecate the renderer parameter to Figure.tight_layout.
We only ever use the renderer instance cached on the Figure anyways (except that in `Figure.draw` we need to cache it earlier). After the parameter is removed, the signature of Figure.tight_layout will match the one of pyplot.tight_layout and we'll be able to dedupe the latter by just adding tight_layout to the list of functions autogenerated by boilerplate.py.
1 parent 74e9dc7 commit 1b7454d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Deprecations
2+
````````````
3+
4+
The ``renderer`` parameter to `.Figure.tight_layout` is deprecated; this method
5+
now always uses the renderer instance cached on the `.Figure`.

lib/matplotlib/figure.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ def draw(self, renderer):
16951695
Render the figure using :class:`matplotlib.backend_bases.RendererBase`
16961696
instance *renderer*.
16971697
"""
1698+
self._cachedRenderer = renderer
16981699

16991700
# draw the figure bounding box, perhaps none for white figure
17001701
if not self.get_visible():
@@ -1729,8 +1730,7 @@ def draw(self, renderer):
17291730
self.execute_constrained_layout(renderer)
17301731
if self.get_tight_layout() and self.axes:
17311732
try:
1732-
self.tight_layout(renderer,
1733-
**self._tight_parameters)
1733+
self.tight_layout(**self._tight_parameters)
17341734
except ValueError:
17351735
pass
17361736
# ValueError can occur when resizing a window.
@@ -1743,7 +1743,6 @@ def draw(self, renderer):
17431743
finally:
17441744
self.stale = False
17451745

1746-
self._cachedRenderer = renderer
17471746
self.canvas.draw_event(renderer)
17481747

17491748
def draw_artist(self, a):
@@ -2450,6 +24 95B9 49,7 @@ def execute_constrained_layout(self, renderer=None):
24502449
renderer = layoutbox.get_renderer(fig)
24512450
do_constrained_layout(fig, renderer, h_pad, w_pad, hspace, wspace)
24522451

2452+
@cbook._delete_parameter("3.2", "renderer")
24532453
def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
24542454
rect=None):
24552455
"""
@@ -2462,8 +2462,7 @@ def tight_layout(self, renderer=None, pad=1.08, h_pad=None, w_pad=None,
24622462
Parameters
24632463
----------
24642464
renderer : subclass of `~.backend_bases.RendererBase`, optional
2465-
Defaults to the renderer for the figure.
2466-
2465+
Defaults to the renderer for the figure. Deprecated.
24672466
pad : float, optional
24682467
Padding between the figure edge and the edges of subplots,
24692468
as a fraction of the font size.

0 commit comments

Comments
 (0)
0