@@ -1094,6 +1094,8 @@ def _process_values(self):
10941094 elif isinstance (self .norm , colors .NoNorm ):
10951095 # NoNorm has N blocks, so N+1 boundaries, centered on integers:
10961096 b = np .arange (self .cmap .N + 1 ) - .5
1097+ elif self .boundaries is not None :
1098+ b = self .boundaries
10971099 else :
10981100 # otherwise make the boundaries from the size of the cmap:
10991101 N = self .cmap .N + 1
@@ -1110,7 +1112,8 @@ def _process_values(self):
11101112 self .norm .vmax = 1
11111113 self .norm .vmin , self .norm .vmax = mtransforms .nonsingular (
11121114 self .norm .vmin , self .norm .vmax , expander = 0.1 )
1113- if not isinstance (self .norm , colors .BoundaryNorm ):
1115+ if (not isinstance (self .norm , colors .BoundaryNorm ) and
1116+ (self .boundaries is None )):
11141117 b = self .norm .inverse (b )
11151118
11161119 self ._boundaries = np .asarray (b , dtype = float )
@@ -1132,18 +1135,15 @@ def _mesh(self):
11321135 norm = copy .deepcopy (self .norm )
11331136 norm .vmin = self .vmin
11341137 norm .vmax = self .vmax
1135- x = np .array ([0.0 , 1.0 ])
11361138 y , extendlen = self ._proportional_y ()
11371139 # invert:
11381140 if (isinstance (norm , (colors .BoundaryNorm , colors .NoNorm )) or
1139- (self .__scale == 'manual' )):
1140- # if a norm doesn't have a named scale, or we are not using a norm:
1141- dv = self .vmax - self .vmin
1142- y = y * dv + self .vmin
1141+ self .boundaries is not None ):
1142+ y = y * (self .vmax - self .vmin ) + self .vmin # not using a norm.
11431143 else :
11441144 y = norm .inverse (y )
11451145 self ._y = y
1146- X , Y = np .meshgrid (x , y )
1146+ X , Y = np .meshgrid ([ 0. , 1. ] , y )
11471147 if self .orientation == 'vertical' :
11481148 return (X , Y , extendlen )
11491149 else :
@@ -1183,8 +1183,8 @@ def _reset_locator_formatter_scale(self):
11831183 self ._set_scale ('function' , functions = funcs )
11841184 elif self .spacing == 'proportional' :
11851185 self ._set_scale ('linear' )
1186- elif hasattr (self .norm , '_scale' ) and self . norm . _scale is not None :
1187- # use the norm's scale:
1186+ elif getattr (self .norm , '_scale' , None ) :
1187+ # use the norm's scale (if it exists and is not None) :
11881188 self ._set_scale (self .norm ._scale )
11891189 elif type (self .norm ) is colors .Normalize :
11901190 # plain Normalize:
@@ -1234,7 +1234,8 @@ def _proportional_y(self):
12341234 Return colorbar data coordinates for the boundaries of
12351235 a proportional colorbar, plus extension lengths if required:
12361236 """
1237- if isinstance (self .norm , colors .BoundaryNorm ):
1237+ if (isinstance (self .norm , colors .BoundaryNorm ) or
1238+ self .boundaries is not None ):
12381239 y = (self ._boundaries - self ._boundaries [self ._inside ][0 ])
12391240 y = y / (self ._boundaries [self ._inside ][- 1 ] -
12401241 self ._boundaries [self ._inside ][0 ])
0 commit comments