@@ -2419,41 +2419,34 @@ def plot_wireframe(self, X, Y, Z, *, axlim_clip=False, **kwargs):
2419
2419
tX , tY , tZ = np .transpose (X ), np .transpose (Y ), np .transpose (Z )
2420
2420
2421
2421
if rstride :
2422
- rii = list ( range ( 0 , rows , rstride ) )
2422
+ rii = np . arange ( 0 , rows , rstride )
2423
2423
# Add the last index only if needed
2424
2424
if rows > 0 and rii [- 1 ] != (rows - 1 ):
2425
- rii += [ rows - 1 ]
2425
+ rii = np . append ( rii , rows - 1 )
2426
2426
else :
2427
- rii = []
2427
+ rii = np .array ([], dtype = int )
2428
+
2428
2429
if cstride :
2429
- cii = list ( range ( 0 , cols , cstride ) )
2430
+ cii = np . arange ( 0 , cols , cstride )
2430
2431
# Add the last index only if needed
2431
2432
if cols > 0 and cii [- 1 ] != (cols - 1 ):
2432
- cii += [ cols - 1 ]
2433
+ cii = np . append ( cii , cols - 1 )
2433
2434
else :
2434
- cii = []
2435
+ cii = np . array ([], dtype = int )
2435
2436
2436
2437
if rstride == 0 and cstride == 0 :
2437
2438
raise ValueError ("Either rstride or cstride must be non zero" )
2438
2439
2439
2440
# If the inputs were empty, then just
2440
2441
# reset everything.
2441
2442
if Z .size == 0 :
2442
- rii = []
2443
- cii = []
2444
-
2445
- xlines = [X [i ] for i in rii ]
2446
- ylines = [Y [i ] for i in rii ]
2447
- zlines = [Z [i ] for i in rii ]
2443
+ rii = np .array ([], dtype = int )
2444
+ cii = np .array ([], dtype = int )
2448
2445
2449
- txlines = [tX [i ] for i in cii ]
2450
- tylines = [tY [i ] for i in cii ]
2451
- tzlines = [tZ [i ] for i in cii ]
2446
+ row_lines = np .stack ([X [rii ], Y [rii ], Z [rii ]], axis = - 1 )
2447
+ col_lines = np .stack ([tX [cii ], tY [cii ], tZ [cii ]], axis = - 1 )
2452
2448
2453
- lines = ([list (zip (xl , yl , zl ))
2454
- for xl , yl , zl in zip (xlines , ylines , zlines )]
2455
- + [list (zip (xl , yl , zl ))
2456
- for xl , yl , zl in zip (txlines , tylines , tzlines )])
2449
+ lines = np .concatenate ([row_lines , col_lines ])
2457
2450
2458
2451
linec = art3d .Line3DCollection (lines , axlim_clip = axlim_clip , ** kwargs )
2459
2452
self .add_collection (linec )
0 commit comments