From e9f0839352b7dad3d2c23e4f3a95e7ac418fed86 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell <tcaswell@gmail.com> Date: Sun, 16 Nov 2014 14:14:32 -0500 Subject: [PATCH 1/2] BUG : fix #3805 Enusure that norm.v{min,max} are not `None` before expanding them to ensure that 0 < vmax-vmin. --- lib/matplotlib/colorbar.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 6862105bc36e..2cc294ed4c40 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -653,12 +653,14 @@ def _process_values(self, b=None): self._values = v return else: - self.norm.vmin, self.norm.vmax = mtrans.nonsingular(self.norm.vmin, - self.norm.vmax, - expander=0.1) if not self.norm.scaled(): self.norm.vmin = 0 self.norm.vmax = 1 + + self.norm.vmin, self.norm.vmax = mtrans.nonsingular(self.norm.vmin, + self.norm.vmax, + expander=0.1) + b = self.norm.inverse(self._uniform_y(self.cmap.N + 1)) if self._extend_lower(): b[0] = b[0] - 1 From 661db3f26154179b04c9270909c498fbcd7e61cf Mon Sep 17 00:00:00 2001 From: Thomas A Caswell <tcaswell@gmail.com> Date: Sun, 16 Nov 2014 14:23:40 -0500 Subject: [PATCH 2/2] TST : added ColorbarBase smoketest --- lib/matplotlib/tests/test_colorbar.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/matplotlib/tests/test_colorbar.py b/lib/matplotlib/tests/test_colorbar.py index 0d8194a78253..8cd60e18dd52 100644 --- a/lib/matplotlib/tests/test_colorbar.py +++ b/lib/matplotlib/tests/test_colorbar.py @@ -246,6 +246,13 @@ def test_remove_from_figure_no_gridspec(): _test_remove_from_figure(False) +@cleanup +def test_colorbarbase(): + # smoke test from #3805 + ax = plt.gca() + ColorbarBase(ax, plt.cm.bone) + + if __name__ == '__main__': import nose nose.runmodule(argv=['-s', '--with-doctest'], exit=False)