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