Skip to content

Commit 893dfa3

Browse files
committed
Merge pull request matplotlib#4182 from efiring/colorbar_ticks
BUG : edit tick locations based on vmin and vmax; closes matplotlib#4181
2 parents 03b1b2b + ba7bc0a commit 893dfa3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/matplotlib/colorbar.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,10 +584,13 @@ def _ticker(self):
584584
formatter.set_data_interval(*intv)
585585

586586
b = np.array(locator())
587+
if isinstance(locator, ticker.LogLocator):
588+
eps = 1e-10
589+
b = b[(b <= intv[1] * (1 + eps)) & (b >= intv[0] * (1 - eps))]
590+
else:
591+
eps = (intv[1] - intv[0]) * 1e-10
592+
b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)]
587593
ticks = self._locate(b)
588-
inrange = (ticks > -0.001) & (ticks < 1.001)
589-
ticks = ticks[inrange]
590-
b = b[inrange]
591594
formatter.set_locs(b)
592595
ticklabels = [formatter(t, i) for i, t in enumerate(b)]
593596
offset_string = formatter.get_offset()

0 commit comments

Comments
 (0)