Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb2c2e9

Browse files
committed
FIX
1 parent 3b7443f commit cb2c2e9

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

lib/matplotlib/_layoutgrid.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -502,23 +502,6 @@ def seq_id():
502502
return '%06d' % next(_layoutboxobjnum)
503503

504504

505-
def nonetree(lb):
506-
if lb.parent is None:
507-
nonechildren(lb)
508-
del(lb)
509-
else:
510-
nonetree(lb.parent)
511-
512-
513-
def nonechildren(lb):
514-
if lb is None:
515-
return
516-
for child in lb.children.flat:
517-
nonechildren(child)
518-
del(child)
519-
return
520-
521-
522505
def print_children(lb):
523506
"""Print the children of the layoutbox."""
524507
for child in lb.children:

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,6 @@ def clf(self, keep_observers=False):
18051805
self._axobservers = cbook.CallbackRegistry()
18061806
self._suptitle = None
18071807
if self.get_constrained_layout():
1808-
self._layoutgrid = layoutgrid.nonetree(self._layoutgrid)
18091808
self.init_layoutgrid()
18101809
self.stale = True
18111810

@@ -2573,6 +2572,7 @@ def get_tightbbox(self, renderer, bbox_extra_artists=None):
25732572

25742573
def init_layoutgrid(self):
25752574
"""Initialize the layoutgrid for use in constrained_layout."""
2575+
del(self._layoutgrid)
25762576
self._layoutgrid = layoutgrid.LayoutGrid(
25772577
parent=None, name='figlb')
25782578

lib/matplotlib/tests/test_constrainedlayout.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,11 @@ def test_constrained_layout23():
389389
"""
390390

391391
for i in range(2):
392-
fig, ax = plt.subplots(num="123", constrained_layout=True, clear=True)
392+
fig = plt.figure(constrained_layout=True, clear=True, num="123")
393+
gs = fig.add_gridspec(1, 2)
394+
sub = gs[0].subgridspec(2, 2)
393395
fig.suptitle("Suptitle{}".format(i))
394396

395-
396397
@image_comparison(['test_colorbar_location.png'],
397398
remove_text=True, style='mpl20')
398399
def test_colorbar_location():

0 commit comments

Comments
 (0)