Ridgeline Plot

Workout Duration by Type

Exercise duration distributions for different workout types

Output
Workout Duration by Type
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
workouts = ['Yoga', 'Strength', 'Cardio', 'HIIT', 'CrossFit', 'Pilates', 'Cycling']
duration_means = [55, 65, 45, 30, 50, 50, 60]
duration_stds = [15, 18, 15, 8, 12, 12, 20]

fig, ax = plt.subplots(figsize=(12, 9), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

colors = ['#27F5B0', '#F5276C', '#F54927', '#F5B027', '#6CF527', '#27D3F5', '#4927F5']

x = np.linspace(0, 120, 200)
overlap = 2.0

for i, (workout, mean, std, color) in enumerate(zip(workouts, duration_means, duration_stds, colors)):
    data = np.random.normal(mean, std, 1000)
    data = np.clip(data, 10, None)
    kde = stats.gaussian_kde(data)
    y = kde(x) * 10
    y_offset = i * overlap
    
    ax.fill_between(x, y_offset, y + y_offset, alpha=0.85, color=color, edgecolor='white', linewidth=0.8)
    ax.text(-5, y_offset + 0.3, workout, fontsize=10, color='white', va='center', ha='right', fontweight='500')

ax.set_xlim(-25, 120)
ax.set_ylim(-0.5, len(workouts) * overlap + 2)
ax.set_xlabel('Workout Duration (minutes)', color='white', fontsize=11, fontweight='500')
ax.set_title('Workout Duration Distribution by Type', color='white', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#888888', labelsize=9)
ax.set_yticks([])
for spine in ax.spines.values():
    spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support