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