Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb3f61d1

Browse files
authored
Merge pull request#22144 from jklymak/fix-cl-subgridspec
Fix cl subgridspec
2 parents612cfae +1c5796a commitb3f61d1

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

‎lib/matplotlib/_constrained_layout.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,16 @@ def make_layoutgrids_gs(layoutgrids, gs):
204204
layoutgrids=make_layoutgrids_gs(layoutgrids,parentgs)
205205
subspeclb=layoutgrids[parentgs]
206206
# gridspecfromsubplotspec need an outer container:
207-
iff'{gs}top'notinlayoutgrids:
208-
layoutgrids[f'{gs}top']=mlayoutgrid.LayoutGrid(
207+
# get a unique representation:
208+
rep= (gs,'top')
209+
ifrepnotinlayoutgrids:
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(),

‎lib/matplotlib/tests/test_constrainedlayout.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,26 @@ def test_constrained_layout6():
115115
ticks=ticker.MaxNLocator(nbins=5))
116116

117117

118+
deftest_identical_subgridspec():
119+
120+
fig=plt.figure(constrained_layout=True)
121+
122+
GS=fig.add_gridspec(2,1)
123+
124+
GSA=GS[0].subgridspec(1,3)
125+
GSB=GS[1].subgridspec(1,3)
126+
127+
axa= []
128+
axb= []
129+
foriinrange(3):
130+
axa+= [fig.add_subplot(GSA[i])]
131+
axb+= [fig.add_subplot(GSB[i])]
132+
133+
fig.draw_without_rendering()
134+
# chech first row above second
135+
assertaxa[0].get_position().y0>axb[0].get_position().y1
136+
137+
118138
deftest_constrained_layout7():
119139
"""Test for proper warning if fig not set in GridSpec"""
120140
withpytest.warns(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp