KDE Plot

CPU Temperature Distribution

KDE of processor temperatures under various workloads.

Output
CPU Temperature Distribution
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(204)

idle = np.random.normal(40, 8, 400)
load = np.random.normal(65, 12, 400)
stress = np.random.normal(85, 10, 200)
cpu_temp = np.concatenate([idle, load, stress])
cpu_temp = cpu_temp[(cpu_temp > 25) & (cpu_temp < 105)]

kde = stats.gaussian_kde(cpu_temp)
x = np.linspace(25, 105, 500)
y = kde(x)

colors = ['#1e3a8a', '#3b82f6', '#22d3ee', '#fbbf24', '#f97316', '#dc2626']

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

for i in range(len(x)-1):
    norm_val = (x[i] - 25) / 80
    color_idx = int(norm_val * (len(colors) - 1))
    color_idx = max(0, min(color_idx, len(colors)-1))
    ax.fill_between(x[i:i+2], y[i:i+2], alpha=0.6, color=colors[color_idx])

ax.plot(x, y, color='#374151', linewidth=2.5)

thresholds = [(50, 'Cool'), (70, 'Warm'), (85, 'Hot'), (95, 'Critical')]
for val, label in thresholds:
    ax.axvline(val, color='#9ca3af', linestyle='--', linewidth=1.5, alpha=0.7)
    ax.text(val+1, max(y)*0.9, label, color='#6b7280', fontsize=8, fontweight='bold')

ax.set_xlabel('Temperature (C)', fontsize=12, color='#1f2937', fontweight='500')
ax.set_ylabel('Density', fontsize=12, color='#1f2937', fontweight='500')
ax.set_title('CPU Temperature Distribution Under Load', 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(25, 105)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support