diff --git a/lib/mpl_toolkits/axes_grid1/axes_grid.py b/lib/mpl_toolkits/axes_grid1/axes_grid.py index 3a517b82c306..c5a15f56d0ef 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_grid.py +++ b/lib/mpl_toolkits/axes_grid1/axes_grid.py @@ -499,7 +499,7 @@ def __init__(self, fig, if ngrids is None: ngrids = self._nrows * self._ncols else: - if not 0 <= ngrids < self._nrows * self._ncols: + if not 0 < ngrids <= self._nrows * self._ncols: raise Exception self.ngrids = ngrids diff --git a/lib/mpl_toolkits/tests/test_axes_grid1.py b/lib/mpl_toolkits/tests/test_axes_grid1.py index f01eef6e6f7d..9ed9a92804bb 100644 --- a/lib/mpl_toolkits/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/tests/test_axes_grid1.py @@ -102,6 +102,7 @@ def test_axesgrid_colorbar_log_smoketest(legacy_colorbar): fig = plt.figure() grid = AxesGrid(fig, 111, # modified to be only subplot nrows_ncols=(1, 1), + ngrids=1, label_mode="L", cbar_location="top", cbar_mode="single",