Area Chart

Exponential Decay

Decay curve with half-life annotation.

Output
Exponential Decay
Python
import matplotlib.pyplot as plt
import numpy as np

# Data - Radioactive decay
t = np.linspace(0, 50, 200)
N0 = 1000
half_life = 10
decay_const = np.log(2) / half_life
N = N0 * np.exp(-decay_const * t)

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

# Decay curve with NEON cyan
ax.fill_between(t, 0, N, alpha=0.3, color='#27D3F5')
ax.plot(t, N, color='#27D3F5', linewidth=2.5)

# Half-life markers
for i in range(1, 4):
    t_half = half_life * i
    N_half = N0 / (2**i)
    ax.axvline(t_half, color='#F5B027', linewidth=1, linestyle='--', alpha=0.7)
    ax.axhline(N_half, color='#F5B027', linewidth=1, linestyle='--', alpha=0.7)
    ax.scatter([t_half], [N_half], color='#F5276C', s=80, zorder=5, edgecolors='white', linewidth=1)
    ax.annotate(f't½ × {i}', (t_half, N_half), xytext=(5, 10), textcoords='offset points', 
                color='white', fontsize=9)

# Styling
ax.set_xlabel('Time (years)', color='white', fontsize=11)
ax.set_ylabel('Atoms remaining', color='white', fontsize=11)
ax.set_title('Radioactive Decay (Half-life = 10 years)', 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.set_xlim(0, 50)
ax.set_ylim(0, 1100)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support