8000 Merge pull request #12099 from jklymak/fix-all-cbar-ticks · matplotlib/matplotlib@2c77256 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c77256

Browse files
authored
Merge pull request #12099 from jklymak/fix-all-cbar-ticks
FIX: make sure all ticks show up for colorbar minor tick
2 parents dadb8d0 + fbfa18e commit 2c77256

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/matplotlib/colorbar.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ def __call__(self):
266266
vmin = self._colorbar.norm.vmin
267267
vmax = self._colorbar.norm.vmax
268268
ticks = ticker.AutoMinorLocator.__call__(self)
269-
return ticks[(ticks >= vmin) & (ticks <= vmax)]
269+
rtol = (vmax - vmin) * 1e-10
270+
return ticks[(ticks >= vmin - rtol) & (ticks <= vmax + rtol)]
270271

271272

272273
class _ColorbarLogLocator(ticker.LogLocator):

lib/matplotlib/tests/test_colorbar.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ def test_colorbar_minorticks_on_off():
294294
np.testing.assert_almost_equal(cbar< 8A3F /span>.ax.yaxis.get_minorticklocs(),
295295
np.array([]))
296296

297+
im.set_clim(vmin=-1.2, vmax=1.2)
298+
cbar.minorticks_on()
299+
correct_minorticklocs = np.array([-1.2, -1.1, -0.9, -0.8, -0.7, -0.6,
300+
-0.4, -0.3, -0.2, -0.1, 0.1, 0.2,
301+
0.3, 0.4, 0.6, 0.7, 0.8, 0.9,
302+
1.1, 1.2])
303+
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
304+
correct_minorticklocs)
305+
297306

298307
def test_colorbar_autoticks():
299308
# Test new autotick modes. Needs to be classic because

0 commit comments

Comments
 (0)
0