10000 FIX · matplotlib/matplotlib@de4da22 · GitHub
[go: up one dir, main page]

Skip to content

Commit de4da22

Browse files
committed
FIX
1 parent 4fb120c commit de4da22

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/matplotlib/gridspec.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ def get_grid_positions(self, fig, raw=False):
205205
@staticmethod
206206
def _check_gridspec_exists(figure, nrows, ncols):
207207
"""
208-
Check if the figure already has a gridspec with these dimensions...
208+
Check if the figure already has a gridspec with these dimensions,
209+
or create a new one
209210
"""
210211
gs = None
211212
for ax in figure.get_axes():
@@ -222,6 +223,8 @@ def _check_gridspec_exists(figure, nrows, ncols):
222223
(nrow, ncol) = ggs.get_geometry()
223224
if nrow == nrows and ncol == ncols:
224225
gs = ggs
226+
if gs is None:
227+
gs = GridSpec(nrows, ncols, figure=figure)
225228
return gs
226229

227230

lib/matplotlib/pyplot.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,8 +1313,6 @@ def subplot2grid(shape, loc, rowspan=1, colspan=1, fig=None, **kwargs):
13131313

13141314
rows, cols = shape
13151315
gs = GridSpec._check_gridspec_exists(fig, rows, cols)
1316-
if gs is None:
1317-
gs = GridSpec(rows, cols, figure=fig)
13181316

13191317
subplotspec = gs.new_subplotspec(loc, rowspan=rowspan, colspan=colspan)
13201318
ax = fig.add_subplot(subplotspec, **kwargs)

0 commit comments

Comments
 (0)
0