KDE Plot

Gaming Reaction Time Distribution

KDE of player reaction times in competitive gaming.

Output
Gaming Reaction Time Distribution
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(60)

reaction = np.random.lognormal(5.2, 0.3, 1500)
reaction = reaction[reaction < 500]

kde = stats.gaussian_kde(reaction)
x = np.linspace(100, 450, 500)
y = kde(x)

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

ax.fill_between(x, y, alpha=0.4, color='#F5276C')
ax.plot(x, y, color='#F5276C', linewidth=3)
ax.plot(x, y, color='#F5276C', linewidth=10, alpha=0.15)

tiers = [
    (150, 'Pro', '#6CF527'),
    (200, 'Advanced', '#27D3F5'),
    (250, 'Average', '#F5B027'),
    (350, 'Casual', '#F5276C'),
]
for val, label, color in tiers:
    ax.axvline(val, color=color, linestyle='--', linewidth=1.5, alpha=0.7)
    ax.text(val+5, max(y)*0.85, label, color=color, fontsize=9, fontweight='bold', rotation=90, va='top')

median = np.median(reaction)
ax.axvline(median, color='white', linestyle='-', linewidth=2)
ax.text(median-10, max(y)*0.6, 'Median ' + str(int(median)) + 'ms', color='white', fontsize=10, ha='right', fontweight='bold')

ax.set_xlabel('Reaction Time (ms)', fontsize=12, color='white', fontweight='500')
ax.set_ylabel('Density', fontsize=12, color='white', fontweight='500')
ax.set_title('Gaming Reaction 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.grid(True, alpha=0.1, color='white')
ax.set_xlim(100, 450)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support