Ridgeline Plot

Website Traffic by Hour

Hourly visitor count distributions throughout the day

Output
Website Traffic by Hour
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
hours = ['6 AM', '9 AM', '12 PM', '3 PM', '6 PM', '9 PM', '12 AM']
traffic_means = [500, 2500, 3500, 3000, 4000, 2000, 800]
traffic_stds = [150, 600, 800, 700, 900, 500, 200]

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

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

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

for i, (hour, mean, std, color) in enumerate(zip(hours, traffic_means, traffic_stds, colors)):
    data = np.random.normal(mean, std, 1000)
    data = np.clip(data, 0, None)
    kde = stats.gaussian_kde(data)
    y = kde(x) * 1500
    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(-150, y_offset + 0.3, hour, fontsize=10, color='#1f2937', va='center', ha='right', fontweight='500')

ax.set_xlim(-700, 6000)
ax.set_ylim(-0.5, len(hours) * overlap + 2)
ax.set_xlabel('Visitors per Hour', color='#1f2937', fontsize=11, fontweight='500')
ax.set_title('Website Traffic Distribution by Hour', 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