3D Trisurf

Acoustic Membrane Mode Trisurf

Circular membrane vibration mode from polar sampling in blue-violet gradient.

Output
Acoustic Membrane Mode Trisurf
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import special
from matplotlib.colors import LinearSegmentedColormap

# Polar sampling
n_radii = 15
n_angles = 50
radii = np.linspace(0.05, 1, n_radii)
angles = np.linspace(0, 2*np.pi, n_angles, endpoint=False)[..., np.newaxis]

x = np.append(0, (radii * np.cos(angles)).flatten())
y = np.append(0, (radii * np.sin(angles)).flatten())
r = np.sqrt(x**2 + y**2)
theta = np.arctan2(y, x)

# Membrane mode (m=2, n=1)
m, n = 2, 1
z = special.jn(m, special.jn_zeros(m, n)[-1] * r) * np.cos(m * theta)

# Custom colormap
colors = ['#ffffff', '#ddd6fe', '#276CF5', '#8b5cf6', '#c4b5fd']
cmap = LinearSegmentedColormap.from_list('blue_violet', colors, N=256)

fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')

surf = ax.plot_trisurf(x, y, z, cmap=cmap, alpha=0.85, linewidth=0.1, edgecolor='#33333310')

ax.set_xlabel('X', fontsize=10, color='#374151', labelpad=10)
ax.set_ylabel('Y', fontsize=10, color='#374151', labelpad=10)
ax.set_zlabel('Displacement', fontsize=10, color='#374151', labelpad=10)
ax.set_title("Acoustic Membrane Mode Trisurf", fontsize=14, color='#1f2937', fontweight='bold', pad=20)

ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')

ax.view_init(elev=30, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support