Calendar Heatmap
Sales Performance Calendar
Daily sales revenue heatmap showing peak performance days.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.patches as mpatches
np.random.seed(111)
days = 365
# Higher sales on weekdays, peaks on Fridays
sales = np.zeros(days)
for i in range(days):
dow = i % 7
if dow < 5: # Weekday
base = np.random.normal(50, 20)
if dow == 4: # Friday peak
base *= 1.3
else: # Weekend
base = np.random.normal(25, 10)
sales[i] = max(0, base)
sales_levels = np.digitize(sales, bins=[0, 20, 35, 50, 65, 80]) - 1
weeks = 53
data = np.zeros((7, weeks))
for i, val in enumerate(sales_levels):
week = i // 7
day = i % 7
if week < weeks:
data[day, week] = val
colors = ['#0a0a0f', '#14532d', '#15803d', '#22c55e', '#4ade80', '#86efac']
cmap = LinearSegmentedColormap.from_list('sales', colors, N=256)
fig, ax = plt.subplots(figsize=(16, 4), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')
im = ax.imshow(data, cmap=cmap, aspect='auto', vmin=0, vmax=5)
ax.set_yticks(range(7))
ax.set_yticklabels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], fontsize=9, color='#e2e8f0')
ax.set_xticks(range(0, 52, 4))
ax.set_xticklabels(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', ''],
fontsize=9, color='#e2e8f0')
ax.set_title('Daily Sales Revenue Performance', fontsize=16, color='white', fontweight='bold', pad=15)
for i in range(8):
ax.axhline(y=i-0.5, color='#1e293b', linewidth=0.5)
for i in range(weeks+1):
ax.axvline(x=i-0.5, color='#1e293b', linewidth=0.5)
ax.tick_params(colors='#e2e8f0', length=0)
for spine in ax.spines.values():
spine.set_visible(False)
legend_elements = [mpatches.Patch(facecolor=c, label=l, edgecolor='#334155')
for c, l in zip(colors, ['<20K', '20-35K', '35-50K', '50-65K', '65-80K', '80K+'])]
ax.legend(handles=legend_elements, loc='upper left', bbox_to_anchor=(0, -0.15), ncol=6,
fontsize=8, facecolor='#1e293b', edgecolor='#334155', labelcolor='white')
total = int(np.sum(sales))
ax.annotate(f'Total Revenue: {total:,}K | Best: Friday', xy=(0.98, 1.1), xycoords='axes fraction',
fontsize=11, color='#4ade80', ha='right', fontweight='bold')
plt.tight_layout()
plt.subplots_adjust(bottom=0.25)
plt.show()
Library
Matplotlib
Category
Time Series
More Calendar Heatmap examples
☕