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

Skip to content

Commit 7377faf

Browse files
authored
Merge pull request #17382 from jklymak/fix-properly-check-for-figrue
FIX: properly check figure on gridspec
2 parents 4f95512 + d79498b commit 7377faf

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/matplotlib/gridspec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def subplots(self, *, sharex=False, sharey=False, squeeze=True,
293293
.pyplot.subplot
294294
"""
295295

296-
figure = self[0, 0].get_topmost_subplotspec().get_gridspec().figure
296+
figure = self.figure
297297

298298
if figure is None:
299299
raise ValueError("GridSpec.subplots() only works for GridSpecs "
@@ -555,6 +555,7 @@ def __init__(self, nrows, ncols,
555555
self._wspace = wspace
556556
self._hspace = hspace
557557
self._subplot_spec = subplot_spec
558+
self.figure = self._subplot_spec.get_gridspec().figure
558559
GridSpecBase.__init__(self, nrows, ncols,
559560
width_ratios=width_ratios,
560561
height_ratios=height_ratios)

0 commit comments

Comments
 (0)