Ridgeline Plot

Music Streaming Hours by Day

Weekly listening patterns across different days

Output
Music Streaming Hours by Day
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
base_hours = [2.5, 2.3, 2.4, 2.6, 3.5, 5.0, 4.5]

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

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

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

for i, (day, base, color) in enumerate(zip(days, base_hours, colors)):
    data = np.random.gamma(base, 1, 1000)
    kde = stats.gaussian_kde(data)
    y = kde(x) * 8
    y_offset = i * overlap
    
    ax.fill_between(x, y_offset, y + y_offset, alpha=0.85, color=color, edgecolor='#1f2937', linewidth=0.8)
    ax.text(-0.5, y_offset + 0.3, day, fontsize=10, color='#1f2937', va='center', ha='right', fontweight='500')

ax.set_xlim(-3, 10)
ax.set_ylim(-0.5, len(days) * overlap + 2)
ax.set_xlabel('Hours of Streaming', color='#1f2937', fontsize=11, fontweight='500')
ax.set_title('Music Streaming Hours by Day of Week', 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