Calendar Heatmap

Learning Streak Calendar

Daily learning activity for online courses and skill development.

Output
Learning Streak Calendar
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.patches as mpatches

np.random.seed(369)

# Generate learning minutes
days = 365
learning = np.random.choice([0, 0, 15, 30, 45, 60, 90, 120], size=days, p=[0.15, 0.1, 0.15, 0.2, 0.15, 0.12, 0.08, 0.05])

learn_levels = np.digitize(learning, bins=[0, 1, 15, 30, 60, 90]) - 1

weeks = 53
data = np.zeros((7, weeks))
for i, val in enumerate(learn_levels):
    week = i // 7
    day = i % 7
    if week < weeks:
        data[day, week] = val

# Green learning gradient
colors = ['#0a0a0f', '#052e16', '#15803d', '#22c55e', '#4ade80', '#86efac']
cmap = LinearSegmentedColormap.from_list('learning', 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 Learning - Skill Development', 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, ['None', '<15m', '15-30m', '30-60m', '60-90m', '90m+'])]
ax.legend(handles=legend_elements, loc='upper left', bbox_to_anchor=(0, -0.15), ncol=6, 
          fontsize=8, facecolor='#1e293b', edgecolor='#334155', labelcolor='white')

streak_days = int(np.sum(learning > 0))
total_hours = int(np.sum(learning)) // 60
ax.annotate(f'{streak_days} learning days | {total_hours}h total study time', 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

Did this help you?

Support PyLucid to keep it free & growing

Support