KDE Plot

Website Load Time Distribution

KDE of page load times with performance benchmarks.

Output
Website Load Time Distribution
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(54)

# Load times (log-normal typical for web performance)
load_times = np.random.lognormal(0.8, 0.6, 2000)
load_times = load_times[load_times < 15]

kde = stats.gaussian_kde(load_times)
x = np.linspace(0, 10, 500)
y = kde(x)

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

# Color gradient based on performance
for i in range(len(x)-1):
    if x[i] < 2:
        color = '#6CF527'  # Fast - lime
    elif x[i] < 4:
        color = '#27D3F5'  # Good - cyan
    elif x[i] < 6:
        color = '#F5B027'  # Slow - amber
    else:
        color = '#F5276C'  # Very slow - coral
    ax.fill_between(x[i:i+2], y[i:i+2], alpha=0.6, color=color)

ax.plot(x, y, color='#276CF5', linewidth=3)
ax.plot(x, y, color='#276CF5', linewidth=8, alpha=0.2)

# Benchmarks
benchmarks = [(2, 'Good'), (4, 'Needs Work'), (6, 'Poor')]
for val, label in benchmarks:
    ax.axvline(val, color='#e2e8f0', linestyle='--', linewidth=1.5, alpha=0.7)
    ax.text(val+0.1, max(y)*0.9, label, color='#e2e8f0', fontsize=9, fontweight='bold')

# Core Web Vitals LCP
ax.axvline(2.5, color='#F5B027', linestyle='-', linewidth=2, label='LCP Target (2.5s)')

ax.set_xlabel('Load Time (seconds)', fontsize=12, color='white', fontweight='500')
ax.set_ylabel('Density', fontsize=12, color='white', fontweight='500')
ax.set_title('Website Load Time Distribution', fontsize=16, color='white', fontweight='bold', pad=15)

ax.tick_params(colors='white', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#334155')
ax.legend(loc='upper right', facecolor='#1e293b', edgecolor='#334155', labelcolor='white')
ax.grid(True, alpha=0.1, color='white')
ax.set_xlim(0, 10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support