Skip to content
svgquantile-fan

Quantile fan

What range of futures does a probabilistic forecaster expect, step by step?

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

How to read it

  1. Read the dark line as the history and the coloured line as the median forecast.
  2. Read the widest band as the central 80% (10% to 90%), the narrower ones as smaller central shares.
  3. Watch how the bands widen with the horizon: that is how fast the model's uncertainty grows.

Watch out

  • A pretrained model's bands are its own beliefs, not a calibrated guarantee: check their coverage in a backtest.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Bands pair each quantile below the median with its mirror above (q and 1 − q), so the 10%–90% band covers the central 80% of the forecast distribution.
  • Bands are drawn as overlapping translucent fills, so the darker centre is where several bands overlap; the median is the point forecast.
  • The bands start at the last observed value so the hand-off from history to forecast is visible.

Use with care

Quantiles describe the model's uncertainty, not a guarantee: check how often actual values fell inside them in a backtest.

# Quantile fan — Codesplash Chart Lab (recipe "quantile-fan")
# controls: defaults
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("quantile-fan-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"])

_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")
T = "month"
V = "passengers (thousands)"
Q = "quantile"
hist = df[df[Q].isna()].sort_values(T)
fc = df[df[Q].notna()].pivot_table(index=T, columns=Q, values=V, aggfunc="last").sort_index()
levels = sorted(fc.columns)
fig, ax = plt.subplots(figsize=(8, 4))
ax.plot(hist[T], hist[V], color="black", linewidth=1.4, label="history")
for q in [l for l in levels if l < 0.5]:  # central bands: q to 1 - q
    mirror = min(levels, key=lambda l: abs(l - (1 - q)))
    if abs(mirror - (1 - q)) < 1e-6:
        ax.fill_between(fc.index, fc[q], fc[mirror], color=PALETTE[0], alpha=0.14 + 0.36 / max(1, len(levels) // 2), linewidth=0)
mid = min(levels, key=lambda l: abs(l - 0.5))
ax.plot(fc.index, fc[mid], color=PALETTE[0], linewidth=2, label="median (the forecast)")
ax.legend(fontsize=8)
plt.show()

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