3D Fill Between

3D Sound Wave Propagation

Acoustic visualization of sound wave propagation through a medium.

Output
3D Sound Wave Propagation
Python
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure(figsize=(12, 9), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('#ffffff')

n = 300
t = np.linspace(0, 8*np.pi, n)
z = np.linspace(0, 5, n)

# Decaying sound waves
decay = np.exp(-z / 4)
freq1, freq2 = 1.0, 1.5

x_wave1 = decay * np.sin(freq1 * t)
y_wave1 = decay * np.cos(freq1 * t)

x_wave2 = 0.6 * decay * np.sin(freq2 * t + np.pi/4)
y_wave2 = 0.6 * decay * np.cos(freq2 * t + np.pi/4)

ax.plot(x_wave1, y_wave1, z, linewidth=2.5, color='#3B82F6')
ax.plot(x_wave2, y_wave2, z, linewidth=2, color='#10B981')

# Pressure zones
for i in range(0, n, 5):
    ax.plot([x_wave1[i], x_wave2[i]], [y_wave1[i], y_wave2[i]], [z[i], z[i]], 
            color='#F59E0B', alpha=0.25, linewidth=0.6)

ax.set_xlabel('X', fontsize=11, color='#1f2937')
ax.set_ylabel('Y', fontsize=11, color='#1f2937')
ax.set_zlabel('Distance', fontsize=11, color='#1f2937')
ax.set_title('Sound Wave Propagation', fontsize=14, color='#1f2937', fontweight='bold', pad=15)

ax.tick_params(colors='#374151', labelsize=9)
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.grid(True, alpha=0.3, color='#d1d5db')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support