8000 colorbar: edit tick locations based on vmin and vmax; closes #4181 · matplotlib/matplotlib@ba7bc0a · GitHub
[go: up one dir, main page]

Skip to content

Commit ba7bc0a

Browse filesBrowse files
committed
colorbar: edit tick locations based on vmin and vmax; closes #4181
1 parent 199952b commit ba7bc0a

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)
0