@@ -2446,22 +2446,19 @@ def plot_wireframe(self, X, Y, Z, *, axlim_clip=False, **kwargs):
24462446 row_lines = np .stack ([X [rii ], Y [rii ], Z [rii ]], axis = - 1 )
24472447 col_lines = np .stack ([tX [cii ], tY [cii ], tZ [cii ]], axis = - 1 )
24482448
2449- nr , nc = len (rii ), len (cii )
2450- if nr == nc :
2451- lines = np .concatenate ([row_lines , col_lines ])
2452- elif nr == 0 :
2453- lines = col_lines
2454- elif nc == 0 :
2455- lines = row_lines
2456- else :
2457- lines = np .full ((nr + nc , max (row_lines .shape [1 ], col_lines .shape [1 ]), 3 ),
2458- np .nan )
2459- lines [:nr , :row_lines .shape [1 ], :] = row_lines
2460- lines [nr :, :col_lines .shape [1 ], :] = col_lines
2461-
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 )
24622460 linec = art3d .Line3DCollection (lines , axlim_clip = axlim_clip , ** kwargs )
24632461 self .add_collection (linec )
2464- self .auto_scale_xyz (lines [..., 0 ], lines [..., 1 ], lines [..., 2 ], had_data )
24652462
24662463 return linec
24672464
0 commit comments