Stream Graph

Fitness Activity Types Stream

Stream graph showing popular fitness activities throughout the year with seasonal patterns.

Output
Fitness Activity Types Stream
Python
import matplotlib.pyplot as plt
import numpy as np

COLORS = {
    'layers': ['#EF4444', '#F59E0B', '#10B981', '#3B82F6', '#8B5CF6', '#EC4899'],
    'background': '#ffffff',
    'text': '#1f2937',
    'grid': '#e5e7eb',
}

np.random.seed(1313)
weeks = np.arange(0, 52)

# Fitness activities with seasonal patterns
running = 30 + 15 * np.sin(weeks * np.pi / 26 - np.pi/2) + np.random.normal(0, 3, 52)  # Peak spring/fall
cycling = 25 + 18 * np.sin(weeks * np.pi / 26) + np.random.normal(0, 3, 52)  # Peak summer
swimming = 15 + 20 * np.exp(-((weeks - 30)**2) / 50) + np.random.normal(0, 2, 52)  # Peak summer
gym = 35 + 10 * np.cos(weeks * np.pi / 26) + np.random.normal(0, 3, 52)  # Peak winter
yoga = 20 + 5 * np.sin(weeks * np.pi / 13) + np.random.normal(0, 2, 52)
hiking = 15 + 12 * np.sin(weeks * np.pi / 26) + np.random.normal(0, 2, 52)

data = [np.clip(d, 1, None) for d in [running, cycling, swimming, gym, yoga, hiking]]

fig, ax = plt.subplots(figsize=(14, 6), facecolor=COLORS['background'])
ax.set_facecolor(COLORS['background'])

ax.stackplot(weeks, *data, colors=COLORS['layers'], alpha=0.85, baseline='sym',
             labels=['Running', 'Cycling', 'Swimming', 'Gym', 'Yoga', 'Hiking'])

ax.axhline(0, color=COLORS['grid'], linewidth=0.5)
ax.set_xlim(0, 51)

ax.set_title('Fitness Activities Throughout the Year', color=COLORS['text'], fontsize=14, fontweight='bold', pad=15)
ax.set_xlabel('Week', color=COLORS['text'], fontsize=11)
ax.set_ylabel('Participants (thousands)', color=COLORS['text'], fontsize=11)

# Legend below plot
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12), frameon=False, fontsize=9, ncol=6)

for spine in ax.spines.values():
    spine.set_color(COLORS['grid'])
ax.tick_params(colors=COLORS['text'], labelsize=9)

plt.tight_layout()
plt.subplots_adjust(bottom=0.18)
plt.show()
Library

Matplotlib

Category

Time Series

Did this help you?

Support PyLucid to keep it free & growing

Support