From fc56ea58838047a78eb506ad34f96ecc5fdb0c8f Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Mon, 21 Oct 2019 14:34:30 -0700 Subject: [PATCH] Backport PR #15460: Fix incorrect value check in axes_grid. --- lib/mpl_toolkits/axes_grid1/axes_grid.py | 2 +- lib/mpl_toolkits/tests/test_axes_grid1.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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",