Unstructured coordinates, Smoothed SurfaceΒΆ
Smoothed surface for the Unstructured coordinates example.
import numpy as np
import matplotlib.pyplot as plt
import s3dlib.surface as s3d
# make data: <--- copy from matplotlib examples
np.random.seed(1)
x = np.random.uniform(-3, 3, 256)
y = np.random.uniform(-3, 3, 256)
z = (1 - x/2 + x**5 + y**3) * np.exp(-x**2 - y**2)
verts = np.array([x,y,z]).T
# Construct figure, add surface, plot ..........................
fig = plt.figure(figsize=(7,3.5))
fig.text(0.50,.95,'Color & Geometric Smoothing', ha='center', va='center',fontsize='x-large')
fig.text(0.25,.05,'shade()', ha='center', va='center')
fig.text(0.75,.05,'triangulate(4)\nshade(flat=False)', ha='center', va='center')
for i in range(2) :
ax = fig.add_subplot(121+i, projection='3d')
ax.set(xticks=[-3,0,3],yticks=[-3,0,3],zticks=[0,1] )
ax.tick_params(labelcolor='w')
ax.set_proj_type('ortho')
ax.xaxis.set_pane_color([1,1,1])
ax.yaxis.set_pane_color([1,1,1])
ax.zaxis.set_pane_color([1,1,1])
surface = s3d.PlanarSurface.pntsurf(verts)
if i==1 :
surface.triangulate(4)
surface.map_cmap_from_op(cmap='Blues')
surface.shade(flat=False).hilite(flat=False, focus=2)
else :
surface.map_cmap_from_op(cmap='Blues')
surface.shade()
s3d.auto_scale(ax,surface)
ax.add_collection3d(surface)
fig.tight_layout(pad=1.0)
plt.show()