@@ -467,12 +467,16 @@ def do_3d_projection(self):
467
467
# broadcast mask to 3D
468
468
viewlim_mask = viewlim_mask [..., np .newaxis ].repeat (3 , axis = - 1 )
469
469
mask = mask | viewlim_mask
470
- xyzs = np .ma .array (proj3d ._proj_transform_vectors (segments , self .axes .M ), mask = mask )
470
+ xyzs = np .ma .array (proj3d ._proj_transform_vectors (segments , self .axes .M ),
471
+ mask = mask )
471
472
segments_2d = xyzs [..., 0 :2 ]
8000
472
473
LineCollection .set_segments (self , segments_2d )
473
474
474
475
# FIXME
475
- minz = min (xyzs [..., 2 ].min (), 1e9 )
476
+ if len (xyzs ) > 0 :
477
+ minz = min (xyzs [..., 2 ].min (), 1e9 )
478
+ else :
479
+ minz = np .nan
476
480
return minz
477
481
478
482
@@ -872,7 +876,8 @@ def do_3d_projection(self):
872
876
mask = mask | xyz .mask
873
877
if self ._axlim_clip :
874
878
mask = mask | _viewlim_mask (* self ._offsets3d , self .axes )
875
- mask = np .broadcast_to (mask , (len (self ._offsets3d ), * self ._offsets3d [0 ].shape ))
879
+ mask = np .broadcast_to (mask ,
880
+ (len (self ._offsets3d ), * self ._offsets3d [0 ].shape ))
876
881
xyzs = np .ma .array (self ._offsets3d , mask = mask )
877
882
else :
878
883
xyzs = self ._offsets3d
@@ -1083,13 +1088,14 @@ def get_vector(self, segments3d):
1083
1088
return self ._get_vector (segments3d )
1084
1089
1085
1090
def _get_vector (self , segments3d ):
1086
- """Optimize points for projection.
1091
+ """
1092
+ Optimize points for projection.
1087
1093
1088
1094
Parameters
1089
1095
----------
1090
1096
segments3d : NumPy array or list of NumPy arrays
1091
1097
List of vertices of the boundary of every segment. If all paths are
1092
- of equal length and this argument is a NumPy arrray , then it should
1098
+ of equal length and this argument is a NumPy array , then it should
1093
1099
be of shape (num_faces, num_vertices, 3).
1094
1100
"""
1095
1101
if isinstance (segments3d , np .ndarray ):
@@ -1175,8 +1181,7 @@ def do_3d_projection(self):
1175
1181
if self ._edge_is_mapped :
1176
1182
self ._edgecolor3d = self ._edgecolors
1177
1183
1178
-
1179
- needs_masking = self ._invalid_vertices is not False
1184
+ needs_masking = np .any (self ._invalid_vertices )
1180
1185
num_faces = len (self ._faces )
1181
1186
mask = self ._invalid_vertices
1182
1187
@@ -1207,30 +1212,39 @@ def do_3d_projection(self):
1207
1212
else :
1208
1213
cedge = cedge .repeat (num_faces , axis = 0 )
1209
1214
1210
- face_z = self ._zsortfunc (pzs , axis = - 1 )
1215
+ if len (pzs ) > 0 :
1216
+ face_z = self ._zsortfunc (pzs , axis = - 1 )
1217
+ else :
1218
+ face_z = pzs
1211
1219
if needs_masking :
1212
1220
face_z = face_z .data
1213
1221
face_order = np .argsort (face_z , axis = - 1 )[::- 1 ]
1214
1222
1215
- faces_2d = pfaces [face_order , :, :2 ]
1216
- if self ._codes3d is not None :
1223
+ if len (pfaces ) > 0 :
1224
+ faces_2d = pfaces [face_order , :, :2 ]
1225
+ else :
1226
+ faces_2d = pfaces
1227
+ if self ._codes3d is not None and len (self ._codes3d ) > 0 :
1217
1228
if needs_masking :
1218
1229
segment_mask = ~ mask [face_order , :]
1219
1230
faces_2d = [face [mask , :] for face , mask
1220
1231
in zip (faces_2d , segment_mask )]
1221
1232
codes = [self ._codes3d [idx ] for idx in face_order ]
1222
1233
PolyCollection .set_verts_and_codes (self , faces_2d , codes )
1223
1234
else :
1224
- if needs_masking :
1235
+ if needs_masking and len ( faces_2d ) > 0 :
1225
1236
invalid_vertices_2d = np .broadcast_to (
1226
1237
mask [face_order , :, None ],
1227
1238
faces_2d .shape )
1228
1239
faces_2d = np .ma .MaskedArray (
1229
1240
faces_2d , mask = invalid_vertices_2d )
1230
1241
PolyCollection .set_verts (self , faces_2d , self ._closed )
1231
1242
1232
- self ._facecolors2d = cface [face_order ]
1233
- if len (self ._edgecolor3d ) == len (cface ):
1243
+ if len (cface ) > 0 :
1244
+ self ._facecolors2d = cface [face_order ]
1245
+ else :
1246
+ self ._facecolors2d = cface
1247
+ if len (self ._edgecolor3d ) == len (cface ) and len (cedge ) > 0 :
1234
1248
self ._edgecolors2d = cedge [face_order ]
1235
1249
else :
1236
1250
self ._edgecolors2d = self ._edgecolor3d
0 commit comments