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

Skip to content

Commit eb411d0

Browse files
committed
Add unit tests
Add unit tests
1 parent 3dca9fd commit eb411d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/matplotlib/tests/test_colorbar.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,24 @@ def test_colorbar_minorticks_on_off():
307307
np.testing.assert_almost_equal(cbar.ax.yaxis.get_minorticklocs(),
308308
correct_minorticklocs)
309309

310+
# tests for github issue #13257 and PR #13265
311+
data = np.random.uniform(low=1, high=10, size=(20, 20))
312+
313+
fig, ax = plt.subplots()
314+
im = ax.pcolormesh(data, norm=LogNorm())
315+
cbar = fig.colorbar(im)
316+
default_minorticklocks = cbar.ax.yaxis.get_minorticklocs()
317+
318+
# test that minorticks turn off for LogNorm
319+
cbar.minorticks_off()
320+
assert np.array_equal(cbar.ax.yaxis.get_minorticklocs(),
321+
np.array([]))
322+
323+
# test that minorticks turn back on for LogNorm
324+
cbar.minorticks_on()
325+
assert np.array_equal(cbar.ax.yaxis.get_minorticklocs(),
326+
default_minorticklocks)
327+
310328

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

0 commit comments

Comments
 (0)