Area Chart
Seismic Wave Visualization
Earthquake seismograph reading with P and S waves
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(42)
t = np.linspace(0, 30, 3000) # 30 seconds
# Seismic signal
noise = np.random.normal(0, 0.05, len(t))
p_wave_start = 5
s_wave_start = 12
signal = noise.copy()
# P-wave (faster, smaller)
p_mask = (t >= p_wave_start) & (t < p_wave_start + 4)
signal[p_mask] += 0.3 * np.sin(10 * np.pi * (t[p_mask] - p_wave_start)) * np.exp(-(t[p_mask] - p_wave_start - 1)**2)
# S-wave (slower, larger)
s_mask = (t >= s_wave_start) & (t < s_wave_start + 10)
signal[s_mask] += 0.8 * np.sin(5 * np.pi * (t[s_mask] - s_wave_start)) * np.exp(-(t[s_mask] - s_wave_start - 3)**2 / 5)
fig, ax = plt.subplots(figsize=(12, 5), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
ax.fill_between(t, 0, signal, where=(signal >= 0), alpha=0.5, color='#6CF527')
ax.fill_between(t, 0, signal, where=(signal < 0), alpha=0.5, color='#F5276C')
ax.plot(t, signal, color='white', linewidth=0.5)
# Wave annotations
ax.annotate('P-Wave', xy=(p_wave_start + 1, 0.3), color='#27D3F5', fontsize=11, fontweight='bold')
ax.annotate('S-Wave', xy=(s_wave_start + 3, 0.7), color='#F5B027', fontsize=11, fontweight='bold')
ax.axhline(0, color='#333333', linewidth=0.5)
ax.set_xlabel('Time (seconds)', color='white', fontsize=11)
ax.set_ylabel('Ground Motion', color='white', fontsize=11)
ax.set_title('Seismograph Reading - M4.5 Earthquake', color='white', fontsize=14, fontweight='bold', pad=15)
ax.tick_params(colors='#888888', labelsize=9)
for spine in ax.spines.values():
spine.set_color('#333333')
ax.set_xlim(0, 30)
ax.set_ylim(-1, 1)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Area Chart examples
☕