@@ -852,12 +852,14 @@ def __init__(self, ax, *args,
852852 aa = self .antialiased
853853 if aa is not None :
854854 aa = (self .antialiased ,)
855- # Default zorder taken from LineCollection
855+ # Default zorder taken from LineCollection, which is higher than
856+ # for filled contours so that lines are displayed on top.
856857 self ._contour_zorder = kwargs .pop ('zorder' , 2 )
857858
858859 self .collections [:] = [
859- mcoll .LineCollection (
860- segs ,
860+ mcoll .PathCollection (
861+ self ._make_paths (segs , None ),
862+ facecolors = "none" ,
861863 antialiaseds = aa ,
862864 linewidths = width ,
863865 linestyles = [lstyle ],
@@ -1024,7 +1026,10 @@ def _make_paths(self, segs, kinds):
10241026 return [mpath .Path (seg , codes = kind )
10251027 for seg , kind in zip (segs , kinds )]
10261028 else :
1027- return [mpath .Path (seg ) for seg in segs ]
1029+ # Explicit comparison of first and last points in segment is faster
1030+ # than the more elegant np.array_equal(seg[0], seg[-1]).
1031+ return [mpath .Path (seg , closed = (seg [0 , 0 ] == seg [- 1 , 0 ]
1032+ and seg [0 , 1 ] == seg [- 1 , 1 ])) for seg in segs ]
10281033
10291034 def changed (self ):
10301035 tcolors = [(tuple (rgba ),)
@@ -1038,7 +1043,7 @@ def changed(self):
10381043 # update the collection's hatch (may be None)
10391044 collection .set_hatch (hatch )
10401045 else :
1041- collection .set_color (color )
1046+ collection .set_edgecolor (color )
10421047 for label , cv in zip (self .labelTexts , self .labelCValues ):
10431048 label .set_alpha (self .alpha )
10441049 label .set_color (self .labelMappable .to_rgba (cv ))
0 commit comments