Skip to content
svgtopics-over-time

Topics over time

Which topics are growing or fading?

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

How to read it

  1. Read a band's thickness as that topic's share or count in that period.
  2. A widening band is a rising topic; the bottom band is the easiest to read.
  3. Switch between share and counts: a share can fall while the count rises.
  1. Callout 1: The largest topic, at the bottom.
  2. Callout 2: A band that thins: this topic is fading.

Watch out

  • Topics come from a model, so check that a topic means the same thing throughout the period.

Defaults

Show
Share of each period
Shares show which topics rise relative to the rest, even if the total volume changes.
Also: Counts
Topics shown
6
Smaller topics are grouped into Other.
Range 2 to 12, step 1

Pinned in the code

  • Rows are summed per period and topic; topics are ranked by total weight, largest at the bottom.
  • Topics beyond the top N join Other. Periods are as given: bin dates before charting.
# Topics over time — Codesplash Chart Lab (recipe "topics-over-time")
# controls: mode=share, top=6
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import to_rgba

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"]
# non-colour encodings per series (same table as the app: series are never told apart by colour alone)
SERIES_HATCHES = ["", "////", "..", "\\\\\\\\", "---", "xx", "|||", "++"]
HATCH_INK = to_rgba(plt.rcParams["axes.facecolor"], 0.5)  # stripes let the chart surface show through

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

T = "month"
K = "topic"
W = "tickets"
TOP, SHARE = 6, True
d = df.dropna(subset=[T, K]).assign(_w=lambda f: f[W].astype(float) if W else 1.0)
totals = d.groupby(K)["_w"].sum().sort_values(ascending=False)
keep = list(totals.index[:TOP])
d["_k"] = d[K].where(d[K].isin(keep), "Other")
wide = d.pivot_table(index=T, columns="_k", values="_w", aggfunc="sum", fill_value=0).sort_index()
wide = wide[keep + (["Other"] if "Other" in wide else [])]  # largest topic at the bottom
if SHARE:
    wide = wide.div(wide.sum(axis=1), axis=0)
fig, ax = plt.subplots(figsize=(8, 4.5))
ax.stackplot(wide.index, wide.T.to_numpy(), labels=wide.columns, colors=PALETTE, alpha=0.85, hatch=[SERIES_HATCHES[i % 8] for i in range(wide.shape[1])], hatchcolor=HATCH_INK, linewidth=0)  # texture per topic, as in the app
ax.set_xlabel(T)
ax.set_ylabel("share" if SHARE else "count")
ax.legend(fontsize=8, loc="upper left")
plt.show()

Needs pandas, numpy, matplotlib · reads topics-over-time-demo.csv · app theme from the optional codesplash helper