@@ -327,6 +327,34 @@ def test_colorbar_minorticks_on_off():
327
327
np .testing .assert_equal (cbar .ax .yaxis .get_minorticklocs (), [])
328
328
329
329
330
+ def test_cbar_minorticks_for_rc_xyminortickvisible ():
331
+ """
332
+ issue gh-16468.
333
+
334
+ Making sure that minor ticks on the colorbar are turned on
335
+ (internally) using the cbar.minorticks_on() method when
336
+ rcParams['xtick.minor.visible'] = True (for horizontal cbar)
337
+ rcParams['ytick.minor.visible'] = True (for vertical cbar).
338
+ Using cbar.minorticks_on() ensures that the minor ticks
339
+ don't overflow into the extend regions of the colorbar.
340
+ """
341
+
342
+ plt .rcParams ['ytick.minor.visible' ] = True
343
+ plt .rcParams ['xtick.minor.visible' ] = True
344
+
345
+ vmin , vmax = 0.4 , 2.6
346
+ fig , ax = plt .subplots ()
347
+ im = ax .pcolormesh ([[1 , 2 ]], vmin = vmin , vmax = vmax )
348
+
349
+ cbar = fig .colorbar (im , extend = 'both' , orientation = 'vertical' )
350
+ assert cbar .ax .yaxis .get_minorticklocs ()[0 ] >= vmin
351
+ assert cbar .ax .yaxis .get_minorticklocs ()[- 1 ] <= vmax
352
+
353
+ cbar = fig .colorbar (im , extend = 'both' , orientation = 'horizontal' )
354
+ assert cbar .ax .xaxis .get_minorticklocs ()[0 ] >= vmin
355
+ assert cbar .ax .xaxis .get_minorticklocs ()[- 1 ] <= vmax
356
+
357
+
330
358
def test_colorbar_autoticks ():
331
359
# Test new autotick modes. Needs to be classic because
332
360
# non-classic doesn't go this route.
0 commit comments