@@ -919,6 +919,30 @@ def test_proportional_colorbars():
919
919
fig .colorbar (CS3 , spacing = spacings [j ], ax = axs [i , j ])
920
920
921
921
922
+ @pytest .mark .parametrize ("extend, coloroffset, res" , [
923
+ ('both' , 1 , [np .array ([[0. , 0. ], [0. , 1. ]]),
924
+ np .array ([[1. , 0. ], [1. , 1. ]]),
925
+ np .array ([[2. , 0. ], [2. , 1. ]])]),
926
+ ('min' , 0 , [np .array ([[0. , 0. ], [0. , 1. ]]),
927
+ np .array ([[1. , 0. ], [1. , 1. ]])]),
928
+ ('max' , 0 , [np .array ([[1. , 0. ], [1. , 1. ]]),
929
+ np .array ([[2. , 0. ], [2. , 1. ]])]),
930
+ ('neither' , - 1 , [np .array ([[1. , 0. ], [1. , 1. ]])])
931
+ ])
932
+ def test_colorbar_extend_drawedges (extend , coloroffset , res ):
933
+ cmap = plt .get_cmap ("viridis" )
934
+ bounds = np .arange (3 )
935
+ nb_colors = len (bounds ) + coloroffset
936
+ colors = cmap (np .linspace (100 , 255 , nb_colors ).astype (int ))
937
+ cmap , norm = mcolors .from_levels_and_colors (bounds , colors , extend = extend )
938
+
939
+ plt .figure (figsize = (5 , 1 ))
940
+ ax = plt .subplot (111 )
941
+ cbar = Colorbar (ax , cmap = cmap , norm = norm , orientation = 'horizontal' ,
942
+ drawedges = True )
943
+ assert np .all (np .equal (cbar .dividers .get_segments (), res ))
944
+
945
+
922
946
def test_negative_boundarynorm ():
923
947
fig , ax = plt .subplots (figsize = (1 , 3 ))
924
948
cmap = plt .get_cmap ("viridis" )
0 commit comments