Skip to content
svgbrushablelollipop

Lollipop chart

How do categories rank on an aggregate, with less ink than bars?

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

How to read it

  1. Read the dot's position: it marks the value, and the stem connects it to zero.
  2. Read top down for the ranking.
  3. Compare gaps between neighbours to see which differences matter.
  1. Callout 1: The dot marks the value.
  2. Callout 2: The stem: a guide back to zero, with less ink than a bar.

Watch out

  • It compares one aggregate and shows no uncertainty. Small categories may rank high by chance.

Defaults

Aggregate
Mean
How rows combine into one number per group or period, such as a sum or a mean.
Also: Sum · Median · Count
Top N
14
How many categories to show.
Range 3 to 30, step 1
Order
Largest first
How rows or groups are ordered.
Also: Smallest first
Value labels
On
Print each value on the chart.

Pinned in the code

  • Same aggregates and ranking as ranked bars (sum, mean, type-7 median, count); stems start at zero so lengths stay comparable.
  • Use for many categories or when values are similar — the dot carries the value, the stem only guides the eye.
# Lollipop chart — Codesplash Chart Lab (recipe "lollipop")
# controls: stat=mean, top=14, order=desc, labels=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("lollipop-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

d = df[["product", "revenue"]].dropna()  # rows with a missing category or value dropped
agg = d.groupby(d["product"].astype(str))["revenue"].agg("mean").rename("value").reset_index()
agg = agg[np.isfinite(agg["value"].astype(float))]
agg = agg.sort_values(["value", "product"], ascending=[False, True]).head(14)  # ties alphabetical

fig, ax = plt.subplots(figsize=(7, 4.5))
y = np.arange(len(agg))[::-1]  # first ranked on top
ax.hlines(y, 0, agg["value"], color=PALETTE[0], linewidth=1.5)
ax.plot(agg["value"], y, "o", color=PALETTE[0], markersize=8)
for yi, v in zip(y, agg["value"]):
    ax.annotate(f"{v:,.0f}" if abs(v) >= 100 else f"{v:.3g}", (v, yi), xytext=(8, 0), textcoords="offset points", va="center", fontsize=8)
ax.axvline(0, color=plt.rcParams["axes.edgecolor"], linewidth=0.8)  # bars/stems start at zero
ax.set_yticks(y, agg["product"])
ax.set_xlabel("Mean revenue")
ax.set_ylabel("product")
plt.show()

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