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