diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 82d5a04f7341..ad50641e6d56 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -674,9 +674,9 @@ def _process_values(self, b=None): b = self.norm.inverse(self._uniform_y(self.cmap.N + 1)) if self._extend_lower(): - b[0] = b[0] - 1 + b[0] = 0.9 * b[0] if self._extend_upper(): - b[-1] = b[-1] + 1 + b[-1] = 1.1 * b[-1] self._process_values(b) def _find_range(self): diff --git a/lib/matplotlib/tests/test_colorbar.py b/lib/matplotlib/tests/test_colorbar.py index de7decb6ec62..06b79e351a6f 100644 --- a/lib/matplotlib/tests/test_colorbar.py +++ b/lib/matplotlib/tests/test_colorbar.py @@ -11,9 +11,11 @@ import matplotlib.pyplot as plt from matplotlib import rcParams from matplotlib.colors import BoundaryNorm +from matplotlib.colors import LogNorm from matplotlib.cm import get_cmap from matplotlib import cm from matplotlib.colorbar import ColorbarBase +from nose.tools import assert_greater_equal def _get_cmap_norms(): @@ -254,7 +256,16 @@ def test_colorbarbase(): ax = plt.gca() ColorbarBase(ax, plt.cm.bone) - +@cleanup +def test_colorbar_lognorm_extension(): + # Issue #5201: empty triangle plotted + # for logarithmic colorbar with vmin < 1.0 + ax = plt.gca() + + cb = ColorbarBase(ax, norm=LogNorm(vmin=1, vmax=1000.0), orientation='vertical', extend='both') + + assert_greater_equal(cb._values[0], 0.0) + @image_comparison( baseline_images=['colorbar_closed_patch'], remove_text=True)