Skip to content

Commit c682ca4

Browse files
committed
FIX: better repr for subgridspecs
1 parent 0548b11 commit c682ca4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/_constrained_layout.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,17 @@ def make_layoutgrids_gs(layoutgrids, gs):
203203
if parentgs not in layoutgrids:
204204
layoutgrids = make_layoutgrids_gs(layoutgrids, parentgs)
205205
subspeclb = layoutgrids[parentgs]
206+
# get a unique representation:
207+
rep = object.__repr__(gs) + 'top'
206208
# gridspecfromsubplotspec need an outer container:
207-
if f'{gs}top' not in layoutgrids:
208-
layoutgrids[f'{gs}top'] = mlayoutgrid.LayoutGrid(
209+
if rep not in layoutgrids:
210+
layoutgrids[rep] = mlayoutgrid.LayoutGrid(
209211
parent=subspeclb,
210212
name='top',
211213
nrows=1, ncols=1,
212214
parent_pos=(subplot_spec.rowspan, subplot_spec.colspan))
213215
layoutgrids[gs] = mlayoutgrid.LayoutGrid(
214-
parent=layoutgrids[f'{gs}top'],
216+
parent=layoutgrids[rep],
215217
name='gridspec',
216218
nrows=gs._nrows, ncols=gs._ncols,
217219
width_ratios=gs.get_width_ratios(),

0 commit comments

Comments
 (0)