@@ -2445,11 +2445,20 @@ def plot_wireframe(self, X, Y, Z, *, axlim_clip=False, **kwargs):
2445
2445
2446
2446
row_lines = np .stack ([X [rii ], Y [rii ], Z [rii ]], axis = - 1 )
2447
2447
col_lines = np .stack ([tX [cii ], tY [cii ], tZ [cii ]], axis = - 1 )
2448
- lines = np .concatenate ([row_lines , col_lines ])
2449
2448
2449
+ # We autoscale twice because autoscaling is much faster with vectorized numpy
2450
+ # arrays, but row_lines and col_lines might not be the same shape, so we can't
2451
+ # stack them to check them in a single pass.
2452
+ # Note that while the column and row grid points are the same, the lines
2453
+ # between them may expand the view limits, so we have to check both.
2454
+ self .auto_scale_xyz (row_lines [..., 0 ], row_lines [..., 1 ], row_lines [..., 2 ],
2455
+ had_data )
2456
+ self .auto_scale_xyz (col_lines [..., 0 ], col_lines [..., 1 ], col_lines [..., 2 ],
2457
+ had_data = True )
2458
+
2459
+ lines = list (row_lines ) + list (col_lines )
2450
2460
linec = art3d .Line3DCollection (lines , axlim_clip = axlim_clip , ** kwargs )
2451
2461
self .add_collection (linec )
2452
- self .auto_scale_xyz (X , Y , Z , had_data )
2453
2462
2454
2463
return linec
2455
2464
0 commit comments