@@ -892,16 +892,38 @@ def _process_values(self, b=None):
892
892
b = self .boundaries
893
893
if b is not None :
894
894
self ._boundaries = np .asarray (b , dtype = float )
895
- if self .values is None :
896
- self ._values = []
897
- for i in range (len (self ._boundaries )- 1 ):
898
- self ._values .extend (np .linspace (self ._boundaries [i ],
899
- self ._boundaries [i + 1 ], 1000 ,
900
- endpoint = False ))
901
- self ._values .extend ([self ._boundaries [- 1 ]])
902
- self ._values = np .array (self ._values )
903
- self ._boundaries = self ._values
895
+ if self .values is None and self .boundaries is not None :
896
+ # define the outside indices
897
+ if self .extend == 'min' :
898
+ i = 0
899
+ elif self .extend == 'max' :
900
+ i = - 1
901
+ elif self .extend == 'both' :
902
+ i = [0 , - 1 ]
903
+ elif self .extend == 'neither' :
904
+ i = slice (None )
905
+ # add values to the colorbar insides
906
+ boundaries_inside = self ._boundaries [self ._inside ]
907
+ self ._values = np .linspace (boundaries_inside [:- 1 ],
908
+ np .roll (boundaries_inside , - 1 )[:- 1 ],
909
+ 1000 , endpoint = False ,
910
+ axis = - 1 ).flatten ()
911
+ self ._values = np .append (self ._values , boundaries_inside [- 1 ])
912
+ # add back in the boundaries for the extensions
913
+ to_add = np .atleast_1d (self ._boundaries [i ])
914
+ self ._boundaries = np .sort (np .concatenate ([to_add ,
915
+ self ._values ]))
916
+ # calculate values at which to plot colors
904
917
self ._values = 0.5 * (self ._values [:- 1 ] + self ._values [1 :])
918
+ # add back in the boundaries for the extensions, display
919
+ # colors of extensions at boundary values
920
+ self ._values = np .sort (np .concatenate ([to_add ,
921
+ self ._values ]))
922
+ if isinstance (self .norm , colors .NoNorm ):
923
+ self ._values = (self ._values + 0.00001 ).astype (np .int16 )
924
+ elif self .values is None and self .boundaries is None :
925
+ self ._values = 0.5 * (self ._boundaries [:- 1 ]
926
+ + self ._boundaries [1 :])
905
927
if isinstance (self .norm , colors .NoNorm ):
906
928
self ._values = (self ._values + 0.00001 ).astype (np .int16 )
907
929
else :
0 commit comments