Skip to content
svgdow-hour

Weekday × hour heatmap

When in the week does activity happen?

Demo data · seed 20261101 · 4,000 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read rows as weekdays and columns as hours.
  2. Find the darkest block: when activity peaks.
  3. Compare weekdays with the weekend rows.
  1. Callout 1: Darkest block: the busiest hours.
  2. Callout 2: Weekend rows: a different pattern?
  3. Callout 3: Hours run along the bottom, in UTC.

Watch out

  • Hours are in UTC here. Check that the time zone matches how you read the pattern.

Defaults

Cell value
Row count
What each cell's colour shows, such as a count, a sum or a mean.
Also: Mean of value

Pinned in the code

  • Weekday and hour are taken in UTC; rows are ISO weekdays (Monday first), columns hours 00–23.
  • Counts map 0 → max on a sequential ramp; means map min → max of the cell means. Empty cells (no rows for a mean) are grey.
  • Convert timestamps to local time before charting if local rhythms matter.
  • All calendar arithmetic is in UTC; timestamps are epoch milliseconds.
# Weekday × hour heatmap — Codesplash Chart Lab (recipe "dow-hour")
# controls: agg=count
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("dow-hour-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["started_at"] = pd.to_datetime(df["started_at"])

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")

AGG = "count"  # "count" rows, or "mean" of the value
d = df.dropna(subset=["started_at"])
dow, hour = d["started_at"].dt.day_of_week, d["started_at"].dt.hour  # UTC; Monday = 0
cells = d.groupby([dow, hour])["session_minutes"].mean() if AGG == "mean" else d.groupby([dow, hour]).size()
grid = cells.unstack().reindex(index=range(7), columns=range(24))
if AGG != "mean":
    grid = grid.fillna(0)  # empty cells count 0; empty means stay blank (grey)
cmap = LinearSegmentedColormap.from_list("seq", SEQ)
cmap.set_bad(GREY)
fig, ax = plt.subplots(figsize=(9, 3.2))
im = ax.imshow(grid.to_numpy(dtype=float), cmap=cmap, aspect="auto", vmin=0 if AGG != "mean" else None)
ax.set_yticks(range(7), ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"])
ax.set_xticks(range(24), [f"{h:02d}" for h in range(24)], fontsize=7)
ax.set_xlabel("hour (UTC)")
ax.grid(False)
fig.colorbar(im, ax=ax, label="mean " + "session_minutes" if AGG == "mean" else "rows")
plt.show()

Needs pandas, numpy, matplotlib · reads dow-hour-demo.csv · app theme from the optional codesplash helper