8000 MNT: add tolerance to colorbar locator methods · matplotlib/matplotlib@17de520 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17de520

Browse files
committed
MNT: add tolerance to colorbar locator methods
1 parent 70c50d1 commit 17de520

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/matplotlib/colorbar.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,9 @@ def __init__(self, colorbar):
239239
def tick_values(self, vmin, vmax):
240240
vmin = max(vmin, self._colorbar.norm.vmin)
241241
vmax = min(vmax, self._colorbar.norm.vmax)
242-
ticks = super().tick_values(vmin, vmax)
243-
return ticks[(ticks >= vmin) & (ticks <= vmax)]
242+
ticks = super().tick_values(self, vmin, vmax)
243+
rtol = (vmax - vmin) * 1e-10
244+
return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)]
244245

245246

246247
class _ColorbarAutoMinorLocator(ticker.AutoMinorLocator):
@@ -295,8 +296,16 @@ def __init__(self, colorbar, *args, **kwargs):
295296
def tick_values(self, vmin, vmax):
296297
vmin = self._colorbar.norm.vmin
297298
vmax = self._colorbar.norm.vmax
299+
<<<<<<< HEAD
298300
ticks = super().tick_values(vmin, vmax)
299301
return ticks[(ticks >= vmin) & (ticks <= vmax)]
302+
=======
303+
ticks = ticker.LogLocator.tick_values(self, vmin, vmax)
304+
rtol = (np.log10(vmax) - np.log10(vmin)) * 1e-10
305+
ticks = ticks[(np.log10(ticks) >= np.log10(vmin) - rtol) &
306+
(np.log10(ticks) <= np.log10(vmax) + rtol)]
307+
return ticks
308+
>>>>>>> MNT: add tolerance to colorbar locator methods
300309

301310

302311
class ColorbarBase(cm.ScalarMappable):

0 commit comments

Comments
 (0)
0