Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b3bbb80

Browse files
committed
MNT: add tolerance to colorbar locator methods
1 parent 294ff2d commit b3bbb80

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/matplotlib/colorbar.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def tick_values(self, vmin, vmax):
240240
vmin = max(vmin, self._colorbar.norm.vmin)
241241
vmax = min(vmax, self._colorbar.norm.vmax)
242242
ticks = ticker.MaxNLocator.tick_values(self, vmin, vmax)
243-
return ticks[(ticks >= vmin) & (ticks <= vmax)]
243+
rtol = (vmax - vmin) * 1e-10
244+
return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)]
244245

245246

246247
class _ColorbarAutoMinorLocator(ticker.AutoMinorLocator):
@@ -296,7 +297,10 @@ def tick_values(self, vmin, vmax):
296297
vmin = self._colorbar.norm.vmin
297298
vmax = self._colorbar.norm.vmax
298299
ticks = ticker.LogLocator.tick_values(self, vmin, vmax)
299-
return ticks[(ticks >= vmin) & (ticks <= vmax)]
300+
rtol = (np.log10(vmax) - np.log10(vmin)) * 1e-10
301+
ticks = ticks[(np.log10(ticks) >= np.log10(vmin) - rtol) &
302+
(np.log10(ticks) <= np.log10(vmax) + rtol)]
303+
return ticks
300304

301305

302306
class ColorbarBase(cm.ScalarMappable):

0 commit comments

Comments
 (0)