@@ -845,10 +845,8 @@ def __init__(self, ax, *args,
845
845
if extend_max :
846
846
cmap .set_over (self .colors [- 1 ])
847
847
848
- if self .filled :
849
- self .collections = cbook .silent_list ('mcoll.PathCollection' )
850
- else :
851
- self .collections = cbook .silent_list ('mcoll.LineCollection' )
848
+ self .collections = cbook .silent_list (None )
849
+
852
850
# label lists must be initialized here
853
851
self .labelTexts = []
854
852
self .labelCValues = []
@@ -869,53 +867,48 @@ def __init__(self, ax, *args,
869
867
if self .filled :
870
868
if self .linewidths is not None :
871
869
cbook ._warn_external ('linewidths is ignored by contourf' )
872
-
873
870
# Lower and upper contour levels.
874
871
lowers , uppers = self ._get_lowers_and_uppers ()
875
-
876
872
# Ensure allkinds can be zipped below.
877
873
if self .allkinds is None :
878
874
self .allkinds = [None ] * len (self .allsegs )
879
-
880
875
# Default zorder taken from Collection
881
876
self ._contour_zorder = kwargs .pop ('zorder' , 1 )
882
- for level , level_upper , segs , kinds in \
883
- zip (lowers , uppers , self .allsegs , self .allkinds ):
884
- paths = self ._make_paths (segs , kinds )
885
877
886
- col = mcoll .PathCollection (
887
- paths ,
878
+ self .collections [:] = [
879
+ mcoll .PathCollection (
880
+ self ._make_paths (segs , kinds ),
888
881
antialiaseds = (self .antialiased ,),
889
882
edgecolors = 'none' ,
890
883
alpha = self .alpha ,
891
884
transform = self .get_transform (),
892
885
zorder = self ._contour_zorder )
893
- self . axes . add_collection ( col , autolim = False )
894
- self .collections . append ( col )
886
+ for level , level_upper , segs , kinds
887
+ in zip ( lowers , uppers , self .allsegs , self . allkinds )]
895
888
else :
896
- tlinewidths = self ._process_linewidths ()
897
- self .tlinewidths = tlinewidths
889
+ self .tlinewidths = tlinewidths = self ._process_linewidths ()
898
890
tlinestyles = self ._process_linestyles ()
899
891
aa = self .antialiased
900
892
if aa is not None :
901
893
aa = (self .antialiased ,)
902
894
# Default zorder taken from LineCollection
903
895
self ._contour_zorder = kwargs .pop ('zorder' , 2 )
904
- for level , width , lstyle , segs in \
905
- zip ( self .levels , tlinewidths , tlinestyles , self . allsegs ):
906
- col = mcoll .LineCollection (
896
+
897
+ self .collections [:] = [
898
+ mcoll .LineCollection (
907
899
segs ,
908
900
antialiaseds = aa ,
909
901
linewidths = width ,
910
902
linestyles = [lstyle ],
911
903
alpha = self .alpha ,
912
904
transform = self .get_transform (),
913
- zorder = self ._contour_zorder )
914
- col . set_label ( '_nolegend_' )
915
- self . axes . add_collection ( col , autolim = False )
916
- self .collections . append ( col )
905
+ zorder = self ._contour_zorder ,
906
+ label = '_nolegend_' )
907
+ for level , width , lstyle , segs
908
+ in zip ( self .levels , tlinewidths , tlinestyles , self . allsegs )]
917
909
918
910
for col in self .collections :
911
+ self .axes .add_collection (col , autolim = False )
919
912
col .sticky_edges .x [:] = [self ._mins [0 ], self ._maxs [0 ]]
920
913
col .sticky_edges .y [:] = [self ._mins [1 ], self ._maxs [1 ]]
921
914
self .axes .update_datalim ([self ._mins , self ._maxs ])
0 commit comments