@@ -575,8 +575,8 @@ def _get_ticker_locator_formatter(self):
575575 else :
576576 locator = _ColorbarAutoLocator (self )
577577 else :
578- b = self ._boundaries [self ._inside ]
579- locator = ticker .FixedLocator (b , nbins = 10 )
578+ b = self .boundaries [self ._inside ]
579+ locator = ticker .FixedLocator (b )
580580
581581 if formatter is None :
582582 if isinstance (self .norm , colors .LogNorm ):
@@ -892,7 +892,37 @@ def _process_values(self, b=None):
892892 b = self .boundaries
893893 if b is not None :
894894 self ._boundaries = np .asarray (b , dtype = float )
895- if self .values is None :
895+ if self .values is None and self .boundaries is not None :
896+ # define the outside additions
897+ if self .extend == 'min' :
898+ to_add = self ._boundaries [0 ]
899+ elif self .extend == 'max' :
900+ to_add = self ._boundaries [- 1 ]
901+ elif self .extend == 'both' :
902+ to_add = self ._boundaries [[0 , - 1 ]]
903+ elif self .extend == 'neither' :
904+ to_add = []
905+ # add values to the colorbar insides
906+ boundaries_inside = self ._boundaries [self ._inside ]
907+ n_between = max ((self .cmap .N - len (to_add )) //
908+ (len (boundaries_inside )- 1 ), 1 )
909+ self ._values = np .linspace (boundaries_inside [:- 1 ],
910+ boundaries_inside [1 :],
911+ n_between , endpoint = False ,
912+ axis = - 1 ).flatten ()
913+ self ._values = np .append (self ._values , boundaries_inside [- 1 ])
914+ # add back in the boundaries for the extensions
915+ self ._boundaries = np .sort (np .concatenate ([to_add ,
916+ self ._values ]))
917+ # calculate values at which to plot colors
918+ self ._values = 0.5 * (self ._values [:- 1 ] + self ._values [1 :])
919+ # add back in the boundaries for the extensions, display
920+ # colors of extensions at boundary values
921+ self ._values = np .sort (np .concatenate ([to_add ,
922+ self ._values ]))
923+ if isinstance (self .norm , colors .NoNorm ):
924+ self ._values = (self ._values + 0.00001 ).astype (np .int16 )
925+ elif self .values is None and self .boundaries is None :
896926 self ._values = 0.5 * (self ._boundaries [:- 1 ]
897927 + self ._boundaries [1 :])
898928 if isinstance (self .norm , colors .NoNorm ):
0 commit comments