Grasp frequency at a glance with a barcode timeline

Visualize

Grasp frequency at a glance with a barcode timeline

Created: Last updated: Read time: 1 min

When only the event dates matter, a barcode timeline is a compact way to show density with vertical lines. It makes period bias and bursts visible at a glance.

import pandas as pd
import matplotlib.pyplot as plt

dates = pd.to_datetime(
    [
        "2024-01-05",
        "2024-01-08",
        "2024-01-12",
        "2024-01-20",
        "2024-02-02",
        "2024-02-07",
        "2024-02-08",
        "2024-02-17",
        "2024-03-01",
        "2024-03-09",
        "2024-03-10",
        "2024-03-24",
        "2024-04-02",
        "2024-04-18",
        "2024-05-01",
    ]
)

fig, ax = plt.subplots(figsize=(6.4, 1.8))
ax.vlines(dates, ymin=0, ymax=1, color="#0f172a", linewidth=2)
ax.set_ylim(0, 1)
ax.set_yticks([])
ax.set_title("Barcode timeline of critical alert dates")
ax.set_xlabel("Date")
ax.set_xlim(dates.min() - pd.Timedelta(days=3), dates.max() + pd.Timedelta(days=3))

ax.tick_params(axis="x", rotation=45)
ax.spines[["left", "top", "right"]].set_visible(False)

fig.tight_layout()

plt.show()

Period bias and bursts are easy to spot.

Reading tips #

  • Denser lines indicate periods of concentrated events. It helps communicate recent congestion or peaks quickly.
  • Varying line height or color lets you encode event types or weights at the same time.
  • For long timelines, split by month or enable scrolling to keep it readable.