KDE Plot

Typing Speed Distribution

KDE of typing speeds with proficiency levels.

Output
Typing Speed Distribution
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(111)

typing = np.random.normal(55, 18, 1000)
typing = typing[(typing > 10) & (typing < 130)]

kde = stats.gaussian_kde(typing)
x = np.linspace(10, 130, 500)
y = kde(x)

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

for i in range(len(x)-1):
    if x[i] < 30:
        color = '#F5276C'
    elif x[i] < 50:
        color = '#F5B027'
    elif x[i] < 70:
        color = '#27D3F5'
    else:
        color = '#6CF527'
    ax.fill_between(x[i:i+2], y[i:i+2], alpha=0.5, color=color)

ax.plot(x, y, color='#27D3F5', linewidth=3)

levels = [(30, 'Beginner'), (50, 'Intermediate'), (70, 'Advanced'), (100, 'Expert')]
for val, label in levels:
    ax.axvline(val, color='#9ca3af', linestyle='--', linewidth=1, alpha=0.7)
    ax.text(val+1, max(y)*0.9, label, color='#6b7280', fontsize=8, rotation=90, va='top')

ax.set_xlabel('Words Per Minute (WPM)', fontsize=12, color='#1f2937', fontweight='500')
ax.set_ylabel('Density', fontsize=12, color='#1f2937', fontweight='500')
ax.set_title('Typing Speed Distribution', fontsize=16, color='#1f2937', fontweight='bold', pad=15)

ax.tick_params(colors='#374151', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#d1d5db')
ax.grid(True, alpha=0.3, color='#e5e7eb')
ax.set_xlim(10, 130)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support