KDE Plot

Cybersecurity Threat Score KDE

Density distribution of threat severity scores by attack type

Output
Cybersecurity Threat Score KDE
Python
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import gaussian_kde

np.random.seed(654)
BG_COLOR = '#0d1117'
TEXT_COLOR = 'white'

# Threat scores (0-100)
malware = np.random.beta(8, 2, 400) * 100
phishing = np.random.beta(5, 3, 400) * 100
ddos = np.random.beta(6, 2.5, 400) * 100

fig, ax = plt.subplots(figsize=(10, 6), facecolor=BG_COLOR)
ax.set_facecolor(BG_COLOR)

x_range = np.linspace(0, 100, 500)

for data, color, label in [(malware, '#C82909', 'Malware'), 
                            (phishing, '#F5B027', 'Phishing'),
                            (ddos, '#4927F5', 'DDoS')]:
    kde = gaussian_kde(data)
    density = kde(x_range)
    ax.plot(x_range, density, color=color, linewidth=2.5, label=label)
    ax.fill_between(x_range, density, alpha=0.3, color=color)

ax.axvline(70, color='#ef4444', linestyle='--', alpha=0.8, linewidth=2)
ax.text(72, ax.get_ylim()[1]*0.8, 'Critical', color='#ef4444', fontsize=10)

ax.set_xlabel('Threat Severity Score', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_ylabel('Density', fontsize=12, color=TEXT_COLOR, fontweight='500')
ax.set_title('Cybersecurity Threat Score Distribution', fontsize=14, color=TEXT_COLOR, fontweight='bold', pad=15)

ax.tick_params(colors='#888888', labelsize=10)
for spine in ax.spines.values():
    spine.set_color('#333333')
ax.legend(facecolor=BG_COLOR, edgecolor='#333333', labelcolor=TEXT_COLOR, fontsize=10)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support