79568422

Date: 2025-04-11 08:59:26
Score: 0.5
Natty:
Report link

I gave it a try, too.

Surface plot with 3d panes

Notes:

Code:

import numpy as np
from mayavi import mlab

# surface data
x_min, x_max = -1, 1
y_min, y_max = -1, 1
X, Y = np.mgrid[x_min:x_max:51j, y_min:y_max:51j]  # 51j means 51 steps
Z = X**2 + Y**2
z_min, z_max = Z.min(), Z.max()

# create a new figure and adjust initial view
white = (1,) * 3
lightgray = (0.75,) * 3
darkgray = (0.25,) * 3
fig = mlab.figure(bgcolor=white, fgcolor=darkgray)
fig.scene.parallel_projection = True
mlab.view(azimuth=60, elevation=60, focalpoint=(0, 0, 0), distance=5.0)
fig.scene.camera.parallel_scale = 5.0  # see https://stackoverflow.com/a/42734442/2414411

# add surface plot
mlab.surf(X, Y, Z)

# add ticks and tick labels
nticks = 5
ax = mlab.axes(xlabel='x', ylabel='y', zlabel='z', nb_labels=nticks)
ax.axes.label_format = '%.1f'

# add background panes
xb, yb = np.mgrid[x_min:x_max:nticks * 1j, y_min:y_max:nticks * 1j]
zb = z_min * np.ones_like(xb)
mlab.mesh(xb, yb, zb, color=lightgray, opacity=0.5)
mlab.mesh(xb, yb, zb, color=darkgray, representation='wireframe')

xb, zb = np.mgrid[x_min:x_max:nticks * 1j, z_min:z_max:nticks * 1j]
yb = y_min * np.ones_like(xb)
mlab.mesh(xb, yb, zb, color=lightgray, opacity=0.5)
mlab.mesh(xb, yb, zb, color=darkgray, representation='wireframe')

yb, zb = np.mgrid[y_min:y_max:nticks * 1j, z_min:z_max:nticks * 1j]
xb = x_min * np.ones_like(yb)
mlab.mesh(xb, yb, zb, color=lightgray, opacity=0.5)
mlab.mesh(xb, yb, zb, color=darkgray, representation='wireframe')

# show figure
mlab.show()
Reasons:
  • Blacklisted phrase (1): stackoverflow
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
Posted by: John