@@ -873,3 +873,24 @@ def test_proportional_colorbars():
873873 CS3 = axs [i , j ].contourf (X , Y , Z , levels , cmap = cmap , norm = norm ,
874874 extend = extends [i ])
875875 fig .colorbar (CS3 , spacing = spacings [j ], ax = axs [i , j ])
876+
877+
878+ def test_negative_boundarynorm ():
879+ fig , ax = plt .subplots (figsize = (1 , 3 ))
880+ cmap = plt .get_cmap ("viridis" )
881+ clevs = np .arange (- 94 , - 85 )
882+ norm = BoundaryNorm (clevs , cmap .N )
883+ cb = fig .colorbar (cm .ScalarMappable (cmap = cmap , norm = norm ), cax = ax )
884+ np .testing .assert_allclose (cb .ax .get_ylim (), [clevs [0 ], clevs [- 1 ]])
885+ np .testing .assert_allclose (cb .ax .get_yticks (), clevs )
886+ clevs = np .arange (85 , 94 )
887+ norm = BoundaryNorm (clevs , cmap .N )
888+ cb = fig .colorbar (cm .ScalarMappable (cmap = cmap , norm = norm ), cax = ax )
889+ np .testing .assert_allclose (cb .ax .get_ylim (), [clevs [0 ], clevs [- 1 ]])
890+ np .testing .assert_allclose (cb .ax .get_yticks (), clevs )
891+
892+ clevs = np .arange (- 3 , 3 )
893+ norm = BoundaryNorm (clevs , cmap .N )
894+ cb = fig .colorbar (cm .ScalarMappable (cmap = cmap , norm = norm ), cax = ax )
895+ np .testing .assert_allclose (cb .ax .get_ylim (), [clevs [0 ], clevs [- 1 ]])
896+ np .testing .assert_allclose (cb .ax .get_yticks (), clevs )
0 commit comments