Ridgeline Plot

App Screen Time by Category

Daily app usage distributions across different categories

Output
App Screen Time by Category
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
categories = ['Social Media', 'Entertainment', 'Productivity', 'Games', 'News', 'Shopping']
time_means = [95, 75, 45, 55, 25, 20]
time_stds = [35, 30, 20, 25, 12, 10]

fig, ax = plt.subplots(figsize=(12, 8), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

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

x = np.linspace(0, 200, 200)
overlap = 2.2

for i, (cat, mean, std, color) in enumerate(zip(categories, time_means, time_stds, colors)):
    data = np.random.gamma(mean/10, 10, 1000)
    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='#374151', linewidth=0.8)
    ax.text(-8, y_offset + 0.3, cat, fontsize=10, color='#1f2937', va='center', ha='right', fontweight='500')

ax.set_xlim(-50, 200)
ax.set_ylim(-0.5, len(categories) * overlap + 2)
ax.set_xlabel('Daily Screen Time (minutes)', color='#1f2937', fontsize=11, fontweight='500')
ax.set_title('App Screen Time by Category', color='#1f2937', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#374151', 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('#e5e7eb')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support