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

Skip to content

Commit 1f0121a

Browse files
authored
Merge pull request #11330 from jklymak/fix-constrained-layout-too-many-constraints
FIX: Don't let constrained_layout counter overflow
2 parents 8eb2359 + b4ef275 commit 1f0121a

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

lib/matplotlib/_constrained_layout.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,7 @@ def _arrange_subplotspecs(gs, hspace=0, wspace=0):
455455
if child._is_subplotspec_layoutbox():
456456
for child2 in child.children:
457457
# check for gridspec children...
458-
name = (child2.name).split('.')[-1][:-3]
459-
if name == 'gridspec':
458+
if child2._is_gridspec_layoutbox():
460459
_arrange_subplotspecs(child2, hspace=hspace, wspace=wspace)
461460
sschildren += [child]
462461
# now arrange the subplots...

lib/matplotlib/_layoutbox.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,20 +354,16 @@ def _is_subplotspec_layoutbox(self):
354354
Helper to check if this layoutbox is the layoutbox of a
355355
subplotspec
356356
'''
357-
name = (self.name).split('.')[-1][:-3]
358-
if name == 'ss':
359-
return True
360-
return False
357+
name = (self.name).split('.')[-1]
358+
return name[:2] == 'ss'
361359

362360
def _is_gridspec_layoutbox(self):
363361
'''
364362
Helper to check if this layoutbox is the layoutbox of a
365363
gridspec
366364
'''
367-
name = (self.name).split('.')[-1][:-3]
368-
if name == 'gridspec':
369-
return True
370-
return False
365+
name = (self.name).split('.')[-1]
366+
return name[:8] == 'gridspec'
371367

372368
def find_child_subplots(self):
373369
'''
@@ -646,7 +642,7 @@ def seq_id():
646642

647643
global _layoutboxobjnum
648644

649-
return ('%03d' % (next(_layoutboxobjnum)))
645+
return ('%06d' % (next(_layoutboxobjnum)))
650646

651647

652648
def print_children(lb):

0 commit comments

Comments
 (0)