@@ -813,6 +813,8 @@ def __init__(self, ax, *args,
813
813
kwargs = self ._process_args (* args , ** kwargs )
814
814
self ._process_levels ()
815
815
816
+ self ._extend_min = self .extend in ['min' , 'both' ]
817
+ self ._extend_max = self .extend in ['max' , 'both' ]
816
818
if self .colors is not None :
817
819
ncolors = len (self .levels )
818
820
if self .filled :
@@ -821,25 +823,27 @@ def __init__(self, ax, *args,
821
823
822
824
# Handle the case where colors are given for the extended
823
825
# parts of the contour.
824
- extend_min = self .extend in ['min' , 'both' ]
825
- extend_max = self .extend in ['max' , 'both' ]
826
+
826
827
use_set_under_over = False
827
828
# if we are extending the lower end, and we've been given enough
828
829
# colors then skip the first color in the resulting cmap. For the
829
830
# extend_max case we don't need to worry about passing more colors
830
831
# than ncolors as ListedColormap will clip.
831
- total_levels = ncolors + int (extend_min ) + int (extend_max )
832
- if len (self .colors ) == total_levels and (extend_min or extend_max ):
832
+ total_levels = (ncolors +
833
+ int (self ._extend_min ) +
834
+ int (self ._extend_max ))
835
+ if (len (self .colors ) == total_levels and
836
+ (self ._extend_min or self ._extend_max )):
833
837
use_set_under_over = True
834
- if extend_min :
838
+ if self . _extend_min :
835
839
i0 = 1
836
840
837
841
cmap = mcolors .ListedColormap (self .colors [i0 :None ], N = ncolors )
838
842
839
843
if use_set_under_over :
840
- if extend_min :
844
+ if self . _extend_min :
841
845
cmap .set_under (self .colors [0 ])
842
- if extend_max :
846
+ if self . _extend_max :
843
847
cmap .set_over (self .colors [- 1 ])
844
848
845
849
self .collections = cbook .silent_list (None )
0 commit comments