@@ -530,28 +530,29 @@ def draw_all(self):
530
530
Calculate any free parameters based on the current cmap and norm,
531
531
and do all the drawing.
532
532
"""
533
- # sets self._boundaries and self._values in real data units .
534
- # takes into account extend values:
533
+ self ._config_axis () # Inline it after deprecation elapses .
534
+ # Set self._boundaries and self._values, including extensions.
535
535
self ._process_values ()
536
- # sets self.vmin and vmax in data units, but just for the part of the
537
- # colorbar that is not part of the extend patch:
538
- self ._find_range ()
539
- # returns the X and Y mesh, *but* this was/is in normalized units:
536
+ # Set self.vmin and self. vmax to first and last boundary, excluding
537
+ # extensions.
538
+ self .vmin , self . vmax = self . _boundaries [ self . _inside ][[ 0 , - 1 ]]
539
+ # Compute the X/ Y mesh, assuming vertical orientation.
540
540
X , Y = self ._mesh ()
541
- C = self ._values [:, np .newaxis ]
542
-
543
- self ._config_axis () # Inline it after deprecation elapses.
541
+ # Extract bounding polygon (the last entry's value (X[0, 1]) doesn't
542
+ # matter, it just matches the CLOSEPOLY code).
543
+ x = np .concatenate ([X [[0 , 1 , - 2 , - 1 ], 0 ], X [[- 1 , - 2 , 1 , 0 , 0 ], 1 ]])
544
+ y = np .concatenate ([Y [[0 , 1 , - 2 , - 1 ], 0 ], Y [[- 1 , - 2 , 1 , 0 , 0 ], 1 ]])
545
+ xy = (np .column_stack ([x , y ]) if self .orientation == 'vertical' else
546
+ np .column_stack ([y , x ])) # Apply orientation.
544
547
# Configure axes limits, patch, and outline.
545
- xy = self ._outline (X , Y )
546
548
xmin , ymin = xy .min (axis = 0 )
547
549
xmax , ymax = xy .max (axis = 0 )
548
550
self .ax .set (xlim = (xmin , xmax ), ylim = (ymin , ymax ))
549
551
self .outline .set_xy (xy )
550
552
self .patch .set_xy (xy )
551
553
self .update_ticks ()
552
-
553
554
if self .filled :
554
- self ._add_solids (X , Y , C )
555
+ self ._add_solids (X , Y , self . _values [:, np . newaxis ] )
555
556
556
557
@cbook .deprecated ("3.3" )
557
558
def config_axis (self ):
@@ -800,19 +801,6 @@ def set_label(self, label, *, loc=None, **kwargs):
800
801
self .ax .set_xlabel (label , ** kwargs )
801
802
self .stale = True
802
803
803
- def _outline (self , X , Y ):
804
- """
805
- Return *x*, *y* arrays of colorbar bounding polygon,
806
- taking orientation into account.
807
- """
808
- N = X .shape [0 ]
809
- ii = [0 , 1 , N - 2 , N - 1 , 2 * N - 1 , 2 * N - 2 , N + 1 , N , 0 ]
810
- x = X .T .reshape (- 1 )[ii ]
811
- y = Y .T .reshape (- 1 )[ii ]
812
- return (np .column_stack ([y , x ])
813
- if self .orientation == 'horizontal' else
814
- np .column_stack ([x , y ]))
815
-
816
804
def _edges (self , X , Y ):
817
805
"""Return the separator line segments; helper for _add_solids."""
818
806
N = X .shape [0 ]
@@ -1008,24 +996,6 @@ def _process_values(self, b=None):
1008
996
b [- 1 ] = b [- 1 ] + 1
1009
997
self ._process_values (b )
1010
998
1011
- def _find_range (self ):
1012
- """
1013
- Set :attr:`vmin` and :attr:`vmax` attributes to the first and
1014
- last boundary excluding extended end boundaries.
1015
- """
1016
- b = self ._boundaries [self ._inside ]
1017
- self .vmin = b [0 ]
1018
- self .vmax = b [- 1 ]
1019
-
1020
- def _central_N (self ):
1021
- """Return the number of boundaries excluding end extensions."""
1022
- nb = len (self ._boundaries )
1023
- if self .extend == 'both' :
1024
- nb -= 2
1025
- elif self .extend in ('min' , 'max' ):
1026
- nb -= 1
1027
- return nb
1028
-
1029
999
def _get_extension_lengths (self , frac , automin , automax , default = 0.05 ):
1030
1000
"""
1031
1001
Return the lengths of colorbar extensions.
@@ -1132,7 +1102,8 @@ def _mesh(self):
1132
1102
norm .vmax = self .vmax
1133
1103
x = np .array ([0.0 , 1.0 ])
1134
1104
if self .spacing == 'uniform' :
1135
- y = self ._uniform_y (self ._central_N ())
1105
+ n_boundaries_no_extensions = len (self ._boundaries [self ._inside ])
1106
+ y = self ._uniform_y (n_boundaries_no_extensions )
1136
1107
else :
1137
1108
y = self ._proportional_y ()
1138
1109
xmid = np .array ([0.5 ])
0 commit comments