Heatmap
Memory Usage Heatmap
Dark theme heatmap showing application memory over time
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.patches import FancyBboxPatch
import matplotlib.patheffects as pe
fig, ax = plt.subplots(figsize=(14, 7), facecolor='#ffffff')
ax.set_facecolor('#ffffff')
np.random.seed(42)
apps = ['Frontend', 'Backend', 'Database', 'Cache', 'Worker', 'Scheduler']
hours = [f'{h:02d}:00' for h in range(0, 24, 2)]
memory = np.random.gamma(3, 200, (len(apps), len(hours)))
# Modern gradient colormap
colors = ['#1e293b', '#334155', '#f59e0b', '#fbbf24', '#fef3c7']
cmap = LinearSegmentedColormap.from_list('modern', colors, N=256)
# Draw rounded rectangles for each cell
cell_width = 0.9
cell_height = 0.85
for i in range(len(apps)):
for j in range(len(hours)):
val = memory[i, j]
color = cmap(val / memory.max())
rect = FancyBboxPatch((j - cell_width/2, i - cell_height/2),
cell_width, cell_height,
boxstyle="round,pad=0.02,rounding_size=0.15",
facecolor=color, edgecolor='#e2e8f0', linewidth=1)
ax.add_patch(rect)
ax.set_xlim(-0.5, len(hours) - 0.5)
ax.set_ylim(-0.5, len(apps) - 0.5)
ax.set_aspect('equal')
ax.invert_yaxis()
ax.set_xticks(range(len(hours)))
ax.set_yticks(range(len(apps)))
ax.set_xticklabels(hours, rotation=45, ha='right', color='#64748b', fontsize=9, fontweight='500')
ax.set_yticklabels(apps, color='#1e293b', fontsize=11, fontweight='500')
# Colorbar with modern styling
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(vmin=0, vmax=memory.max()))
cbar = plt.colorbar(sm, ax=ax, shrink=0.8, aspect=30, pad=0.02)
cbar.set_label('Memory (MB)', 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_xlabel('Hour', fontsize=12, color='#64748b', fontweight='500', labelpad=10)
ax.set_title('Application Memory Usage', fontsize=18, color='#1e293b', fontweight='bold', pad=20,
path_effects=[pe.withStroke(linewidth=3, foreground='#0f172a')])
ax.tick_params(length=0)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Heatmaps & Density
More Heatmap examples
☕