Area Chart

Heartbeat Area

Pulse-like waveform visualization.

Output
Heartbeat Area
Python
import matplotlib.pyplot as plt
import numpy as np

# Data - ECG-like waveform
t = np.linspace(0, 4, 1000)
def ecg_wave(t, period=1):
    t_mod = t % period
    y = np.zeros_like(t)
    # P wave
    mask = (t_mod > 0.1) & (t_mod < 0.2)
    y[mask] = 0.15 * np.sin((t_mod[mask] - 0.1) * np.pi / 0.1)
    # QRS complex
    mask = (t_mod > 0.25) & (t_mod < 0.28)
    y[mask] = -0.1
    mask = (t_mod > 0.28) & (t_mod < 0.32)
    y[mask] = 1.0 * np.sin((t_mod[mask] - 0.28) * np.pi / 0.04)
    mask = (t_mod > 0.32) & (t_mod < 0.35)
    y[mask] = -0.15
    # T wave
    mask = (t_mod > 0.4) & (t_mod < 0.55)
    y[mask] = 0.2 * np.sin((t_mod[mask] - 0.4) * np.pi / 0.15)
    return y

y = ecg_wave(t)

# Figure - DARK THEME
fig, ax = plt.subplots(figsize=(10, 5), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

# ECG line with glow effect
for lw, alpha in [(8, 0.1), (5, 0.2), (2, 0.5)]:
    ax.plot(t, y, color='#F5276C', linewidth=lw, alpha=alpha)
ax.plot(t, y, color='#F5276C', linewidth=1.5)

# Styling
ax.set_xlabel('Time (s)', color='white', fontsize=11)
ax.set_ylabel('mV', color='white', fontsize=11)
ax.set_title('ECG Waveform', 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.yaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.xaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.set_xlim(0, 4)
ax.set_ylim(-0.3, 1.2)

# Heart rate annotation
ax.text(0.98, 0.95, '72 BPM', transform=ax.transAxes, color='#F5276C', 
        fontsize=14, fontweight='bold', ha='right', va='top')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support