From 8f4bfa73b02100e2f62ba96f121661c43e7497de 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 dde0e8dd7ccb..d7e4fa8768cb 100644 --- a/lib/mpl_toolkits/axes_grid1/axes_grid.py +++ b/lib/mpl_toolkits/axes_grid1/axes_grid.py @@ -484,7 +484,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 48b589bdd5b6..a130dd3dcd00 100644 --- a/lib/mpl_toolkits/tests/test_axes_grid1.py +++ b/lib/mpl_toolkits/tests/test_axes_grid1.py @@ -101,6 +101,7 @@ def test_axesgrid_colorbar_log_smoketest(): 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",