KDE Plot

Video Game Score Distribution

KDE of player scores in a competitive video game.

Output
Video Game Score Distribution
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(115)

scores = np.random.normal(2500, 800, 1500)
scores = scores[(scores > 0) & (scores < 5000)]

kde = stats.gaussian_kde(scores)
x = np.linspace(0, 5000, 500)
y = kde(x)

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

ax.fill_between(x, y, alpha=0.4, color='#4927F5')
ax.plot(x, y, color='#4927F5', linewidth=3)

ranks = [
    (1000, 'Bronze', '#F5B027'),
    (2000, 'Silver', '#9ca3af'),
    (3000, 'Gold', '#F5B027'),
    (4000, 'Diamond', '#27D3F5'),
]
for val, label, color in ranks:
    ax.axvline(val, color=color, linestyle='--', linewidth=2, alpha=0.7)
    ax.text(val+50, max(y)*0.9, label, color=color, fontsize=9, fontweight='bold')

ax.set_xlabel('Player Score', fontsize=12, color='#1f2937', fontweight='500')
ax.set_ylabel('Density', fontsize=12, color='#1f2937', fontweight='500')
ax.set_title('Competitive Game Score 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(0, 5000)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support