2D Histogram

CPU Temperature vs Load

2D histogram of CPU temperature readings versus system load percentage.

Output
CPU Temperature vs Load
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

np.random.seed(42)

# CPU metrics
load = np.random.beta(2, 2, 5000) * 100
temp = 35 + load * 0.4 + np.random.normal(0, 5, 5000)
temp = np.clip(temp, 30, 95)

fig, ax = plt.subplots(figsize=(10, 8), facecolor='#020B14')
ax.set_facecolor('#020B14')

# Custom colormap: cyan to red (temperature scale)
colors = ['#020B14', '#0d2d3d', '#27D3F5', '#F5B027', '#C82909']
cmap = LinearSegmentedColormap.from_list('temp', colors, N=256)

h = ax.hist2d(load, temp, bins=50, cmap=cmap, cmin=1)
cbar = plt.colorbar(h[3], ax=ax, pad=0.02)
cbar.set_label('Samples', color='white', fontsize=11)
cbar.ax.yaxis.set_tick_params(color='white')
plt.setp(plt.getp(cbar.ax.axes, 'yticklabels'), color='white')

ax.set_xlabel('CPU Load (%)', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Temperature (°C)', fontsize=11, color='white', fontweight='500')
ax.set_title('CPU Temperature vs Load', fontsize=14, color='white', fontweight='bold', pad=15)

ax.tick_params(colors='white', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support