Skip to content
svgbrushablezoom-overview

Zoom with overview

How do I explore a long series in detail without losing the big picture?

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

How to read it

  1. Use the strip at the bottom to see the whole series.
  2. Drag the window on the strip to choose the detail above.
  3. Check the date range and point count in the corner.
  1. Callout 1: Detail: the selected window.
  2. Callout 2: The draggable window on the overview.
  3. Callout 3: The selected range and its point count.

Watch out

  • The detail's y axis rescales to the window, so moves look larger than they are.

Defaults

Initial window (days)
180
How much of the series the detail view shows when it opens.
Range 7 to 3,650, step 1
Fill under the line
On
Shade the area under the line.

Pinned in the code

  • Drag on the overview to choose the detail window, drag the window to pan, click outside it to recentre, double-click to show everything.
  • The detail y axis rescales to the visible points; the overview always shows the full range (thinned to ≈ 2 points per pixel).
  • The window starts at the last N days of the series (control). Exports show the chart in its current window.
  • All calendar arithmetic is in UTC; timestamps are epoch milliseconds.
# Zoom with overview — Codesplash Chart Lab (recipe "zoom-overview")
# controls: initialDays=180, area=true
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

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("zoom-overview-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["date"] = pd.to_datetime(df["date"])

_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")
d = df.dropna(subset=["date", "close"]).sort_values("date")
end = d["date"].max()
start = end - pd.Timedelta(days=180)  # the detail window starts at the last N days
win = d[d["date"] >= start]
fig, (ax, ov) = plt.subplots(2, 1, figsize=(8, 5), gridspec_kw={"height_ratios": [3, 1]})
ax.plot(win["date"], win["close"], color=PALETTE[0], linewidth=1.4)  # detail y rescales to the window
ax.fill_between(win["date"], win["close"].min(), win["close"], color=PALETTE[0], alpha=0.15, linewidth=0)
ov.plot(d["date"], d["close"], color=REF, linewidth=0.8)  # overview: the full range
ov.axvspan(start, end, color=PALETTE[0], alpha=0.2)
ax.set_ylabel("close")
ov.set_yticks([])
plt.show()

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