diff --git a/lib/matplotlib/colorbar.py b/lib/matplotlib/colorbar.py index 2cc294ed4c40..c4caae295681 100644 --- a/lib/matplotlib/colorbar.py +++ b/lib/matplotlib/colorbar.py @@ -584,10 +584,13 @@ def _ticker(self): formatter.set_data_interval(*intv) b = np.array(locator()) + if isinstance(locator, ticker.LogLocator): + eps = 1e-10 + b = b[(b <= intv[1] * (1 + eps)) & (b >= intv[0] * (1 - eps))] + else: + eps = (intv[1] - intv[0]) * 1e-10 + b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)] ticks = self._locate(b) - inrange = (ticks > -0.001) & (ticks < 1.001) - ticks = ticks[inrange] - b = b[inrange] formatter.set_locs(b) ticklabels = [formatter(t, i) for i, t in enumerate(b)] offset_string = formatter.get_offset()