Heatmap
CPU Temperature Heatmap
Dark theme heatmap showing CPU core temperatures
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.patches import FancyBboxPatch
fig, ax = plt.subplots(figsize=(14, 8), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
np.random.seed(42)
cores = [f'Core {i}' for i in range(8)]
time_points = [f'{i*5}min' for i in range(12)]
temps = 40 + np.random.rand(len(cores), len(time_points)) * 45
colors = ['#1e293b', '#0369a1', '#38bdf8', '#fbbf24', '#f97316', '#ef4444']
cmap = LinearSegmentedColormap.from_list('thermal', colors, N=256)
cell_width = 0.88
cell_height = 0.82
for i in range(len(cores)):
for j in range(len(time_points)):
val = temps[i, j]
color = cmap((val - 40) / 50)
rect = FancyBboxPatch((j - cell_width/2, i - cell_height/2),
cell_width, cell_height,
boxstyle="round,pad=0.02,rounding_size=0.12",
facecolor=color, edgecolor='#e2e8f0', linewidth=1.5)
ax.add_patch(rect)
ax.text(j, i, f'{val:.0f}°', ha='center', va='center',
color='#1e293b', fontsize=9, fontweight='bold')
ax.set_xlim(-0.5, len(time_points) - 0.5)
ax.set_ylim(-0.5, len(cores) - 0.5)
ax.set_aspect('equal')
ax.invert_yaxis()
ax.set_xticks(range(len(time_points)))
ax.set_yticks(range(len(cores)))
ax.set_xticklabels(time_points, rotation=45, ha='right', color='#64748b', fontsize=9, fontweight='500')
ax.set_yticklabels(cores, color='#1e293b', fontsize=10, fontweight='500')
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=40, vmax=90))
cbar = plt.colorbar(sm, ax=ax, shrink=0.8, aspect=30, pad=0.02)
cbar.set_label('Temperature (°C)', color='#1e293b', fontsize=11, fontweight='500')
cbar.ax.yaxis.set_tick_params(color='#64748b')
plt.setp(plt.getp(cbar.ax.axes, 'yticklabels'), color='#64748b')
cbar.outline.set_edgecolor('#e2e8f0')
for spine in ax.spines.values():
spine.set_visible(False)
ax.set_title('CPU Core Temperature Monitor', fontsize=18, color='#1e293b', fontweight='bold', pad=20)
ax.tick_params(length=0)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Heatmap examples
☕