Skip to content

Fix plot_wireframe with nonequal rstride, cstride, plus additional speedups #29435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2445,11 +2445,20 @@ def plot_wireframe(self, X, Y, Z, *, axlim_clip=False, **kwargs):

row_lines = np.stack([X[rii], Y[rii], Z[rii]], axis=-1)
col_lines = np.stack([tX[cii], tY[cii], tZ[cii]], axis=-1)
lines = np.concatenate([row_lines, col_lines])

# We autoscale twice because autoscaling is much faster with vectorized numpy
# arrays, but row_lines and col_lines might not be the same shape, so we can't
# stack them to check them in a single pass.
# Note that while the column and row grid points are the same, the lines
# between them may expand the view limits, so we have to check both.
self.auto_scale_xyz(row_lines[..., 0], row_lines[..., 1], row_lines[..., 2],
had_data)
self.auto_scale_xyz(col_lines[..., 0], col_lines[..., 1], col_lines[..., 2],
had_data=True)

lines = list(row_lines) + list(col_lines)
linec = art3d.Line3DCollection(lines, axlim_clip=axlim_clip, **kwargs)
self.add_collection(linec)
self.auto_scale_xyz(X, Y, Z, had_data)

return linec

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions lib/mpl_toolkits/mplot3d/tests/test_axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,14 @@ def test_wireframe3d():
ax.plot_wireframe(X, Y, Z, rcount=13, ccount=13)


@mpl3d_image_comparison(['wireframe3dasymmetric.png'], style='mpl20')
def test_wireframe3dasymmetric():
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_wireframe(X, Y, Z, rcount=3, ccount=13)


@mpl3d_image_comparison(['wireframe3dzerocstride.png'], style='mpl20')
def test_wireframe3dzerocstride():
fig = plt.figure()
Expand Down
Loading