@@ -2413,29 +2413,34 @@ def plot_wireframe(self, X, Y, Z, *, axlim_clip=False, **kwargs):
2413
2413
rstride = int (max (np .ceil (rows / rcount ), 1 )) if rcount else 0
2414
2414
cstride = int (max (np .ceil (cols / ccount ), 1 )) if ccount else 0
2415
2415
2416
+ if rstride == 0 and cstride == 0 :
2417
+ raise ValueError ("Either rstride or cstride must be non zero" )
2418
+
2416
2419
# We want two sets of lines, one running along the "rows" of
2417
2420
# Z and another set of lines running along the "columns" of Z.
2418
2421
# This transpose will make it easy to obtain the columns.
2419
2422
tX , tY , tZ = np .transpose (X ), np .transpose (Y ), np .transpose (Z )
2420
2423
2421
- if rstride :
2424
+ # Compute the indices of the row and column lines to be drawn
2425
+ if rstride == 0 :
2426
+ rii = np .array ([], dtype = int )
2427
+ elif (rows - 1 ) % rstride == 0 :
2428
+ # last index is hit: rii[-1] == rows - 1
2422
2429
rii = np .arange (0 , rows , rstride )
2423
- # Add the last index only if needed
2424
- if rows > 0 and rii [- 1 ] != (rows - 1 ):
2425
- rii = np .append (rii , rows - 1 )
2426
2430
else :
2427
- rii = np .array ([], dtype = int )
2431
+ # add the last index
2432
+ rii = np .arange (0 , rows + rstride , rstride )
2433
+ rii [- 1 ] = rows - 1
2428
2434
2429
- if cstride :
2435
+ if cstride == 0 :
2436
+ cii = np .array ([], dtype = int )
2437
+ elif (cols - 1 ) % cstride == 0 :
2438
+ # last index is hit: cii[-1] == cols - 1
2430
2439
cii = np .arange (0 , cols , cstride )
2431
- # Add the last index only if needed
2432
- if cols > 0 and cii [- 1 ] != (cols - 1 ):
2433
- cii = np .append (cii , cols - 1 )
2434
2440
else :
2435
- cii = np .array ([], dtype = int )
2436
-
2437
- if rstride == 0 and cstride == 0 :
2438
- raise ValueError ("Either rstride or cstride must be non zero" )
2441
+ # add the last index
2442
+ cii = np .arange (0 , cols + cstride , cstride )
2443
+ cii [- 1 ] = cols - 1
2439
2444
2440
2445
# If the inputs were empty, then just
2441
2446
# reset everything.
0 commit comments