@@ -1091,7 +1091,6 @@ def set_verts(self, verts, closed=True):
1091
1091
connection at the end.
1092
1092
"""
1093
1093
self .stale = True
1094
- # This is much faster than having Path do it one at a time.
1095
1094
if isinstance (verts , np .ma .MaskedArray ):
1096
1095
verts = verts .astype (float ).filled (np .nan )
1097
1096
@@ -1102,7 +1101,9 @@ def set_verts(self, verts, closed=True):
1102
1101
1103
1102
# Fast path for arrays
1104
1103
if isinstance (verts , np .ndarray ):
1105
- verts_pad = np .concatenate ((verts , verts [:, - 1 :]), axis = 1 )
1104
+ verts_pad = np .concatenate ((verts , verts [:, 0 :1 ]), axis = 1 )
1105
+ # Creating the codes once is much faster than having Path do it
1106
+ # separately each time by passing closed=True.
1106
1107
codes = np .empty (verts_pad .shape [1 ], dtype = mpath .Path .code_type )
1107
1108
codes [:] = mpath .Path .LINETO
1108
1109
codes [0 ] = mpath .Path .MOVETO
@@ -1118,11 +1119,7 @@ def set_verts(self, verts, closed=True):
1118
1119
else :
1119
1120
xy = np .asarray (xy )
1120
1121
xy = np .concatenate ([xy , xy [0 :1 ]])
1121
- codes = np .empty (xy .shape [0 ], dtype = mpath .Path .code_type )
1122
- codes [:] = mpath .Path .LINETO
1123
- codes [0 ] = mpath .Path .MOVETO
1124
- codes [- 1 ] = mpath .Path .CLOSEPOLY
1125
- self ._paths .append (mpath .Path (xy , codes ))
1122
+ self ._paths .append (mpath .Path (xy , closed = True ))
1126
1123
else :
1127
1124
self ._paths .append (mpath .Path (xy ))
1128
1125
0 commit comments