Skip to main content

If zero is in the neighborhood

Showing and telling
Advice
Introductory
Invite it in.
Published

November 9, 2026

Modified

November 13, 2026

Entry #100 in Andrew Gelman’s Handy Statistical Lexicon. Original discussion: Graphing advice: if zero is in the neighborhood, invite it in.

Filed under Showing and telling · Advice · Introductory.

Related terms: y-axis range, axis starting at zero, graphing advice.

Source check: ✓ The explanation was checked against the source. The numeric threshold in How it works is our own rule of thumb.

What it is

This is graphing advice about the y-axis. Gelman’s post: “Sometimes zero has no particular meaning (for example when graphing degrees Fahrenheit), but usually it has a clear interpretation, in which case it can be pleasant to include it on the graph. On the other hand, if you’re plotting something that varies from, say 184 to 197, it would typically be a bad idea to extend the axis all the way to zero, as this would destroy your visual resolution.” His advice: “If zero is in the neighborhood, invite it in.” It is a middle path between the old rule that every axis must start at zero and the habit of letting software zoom in on the data range.

Why it matters

Auto-scaled axes that stop just below the data make small changes look dramatic: a rise from 52% to 55% fills the whole panel. Including zero when it’s close keeps that change in proportion. Including zero when it is far from the data just flattens everything into a line along the top. The neighborhood rule keeps the benefits of both conventions.

How it works

Gelman gives no numeric threshold. The rule below, and the simulation that uses it, are our own rule of thumb: let the data range be \([a, b]\) with \(a > 0\). If \(a < 1.5\,(b - a)\), so that the distance from zero to the data is comparable to the data’s own spread, extend the axis to zero. If zero is much farther away, keep the zoomed axis but label it clearly.

Simulated example

A time series whose level you can shift up or down. The left panel uses the software’s default auto-scaled axis. The right panel follows the neighborhood rule.

Show simulation code

The R version uses base R, and the Python version uses NumPy and Matplotlib. Where the simulation draws random numbers, each language draws its own, so exact numbers differ slightly but show the same pattern. The numbered markers in the R code are explained under it.

import {rng, range, fmt} from "../js/stats.js"

viewof level = Inputs.range([2, 200], {value: 5, step: 1, label: "Typical level of the series"})
viewof seed = Inputs.range([1, 500], {value: 100, step: 1, label: "Random seed"})

series = {
  const r = rng(seed);
  let v = level;
  return range(24).map(t => { v += r.normal(0.15, 0.6); return {t, v}; });
}
rule = {
  const lo = Math.min(...series.map(d => d.v)), hi = Math.max(...series.map(d => d.v));
  return {lo, hi, invite: lo <= 0 || lo < 1.5 * (hi - lo)};
}

html`<div style="display:flex; gap:1rem; flex-wrap:wrap">
${Plot.plot({
  ariaLabel: "If zero is in the neighborhood: Software default",
  ariaDescription: "Horizontal axis: Month. Vertical axis: Value. The chart updates with the controls above it, and the summary below the charts states the result in words.",width: 320, height: 240, title: "Software default", y: {grid: true, label: "Value"}, x: {label: "Month"}, marks: [Plot.line(series, {x: "t", y: "v", stroke: "#d6604d", strokeWidth: 2})]})}
${Plot.plot({
  ariaLabel: "If zero is in the neighborhood: Neighborhood rule",
  ariaDescription: "Horizontal axis: Month. Vertical axis: Value. The chart updates with the controls above it, and the summary below the charts states the result in words.",width: 320, height: 240, title: "Neighborhood rule", y: {grid: true, label: "Value", domain: rule.invite ? [0, rule.hi * 1.05] : undefined}, x: {label: "Month"}, marks: [Plot.line(series, {x: "t", y: "v", stroke: "#2166ac", strokeWidth: 2}), Plot.ruleY(rule.invite ? [0] : [])]})}
</div>`
# If zero is in the neighborhood, invite it in.
1level <- 5 # typical level of the series
2set.seed(100)

3v <- level + cumsum(rnorm(24, 0.15, 0.6)) # a series over 24 periods
lo <- min(v)
hi <- max(v)
4invite <- lo <= 0 || lo < 1.5 * (hi - lo) # is zero in the neighborhood?
cat("The data range from ", round(lo, 1), " to ", round(hi, 1), ": ",
  if (invite) {
    "zero is in the neighborhood, so include it"
  } else {
    "zero is far away, so keep the zoomed axis"
  }, "\n",
  sep = ""
)

5par(mfrow = c(1, 2))
plot(1:24, v,
  type = "b", pch = 19, main = "Zoomed axis", xlab = "Period",
  ylab = "Value"
)
plot(1:24, v,
  type = "b", pch = 19, ylim = c(min(0, lo), hi),
  main = "Axis including zero", xlab = "Period", ylab = "Value"
)
1
The page’s control: the typical level of the series.
2
Fixes the random numbers so the run is reproducible.
3
A series over 24 periods.
4
The site’s rule of thumb: invite zero in when its distance from the data is comparable to the data’s own spread.
5
The same series on the software’s zoomed axis and on an axis that includes zero.
# If zero is in the neighborhood, invite it in.
import numpy as np
import matplotlib.pyplot as plt

level = 5  # typical level of the series
rng = np.random.default_rng(100)

v = level + np.cumsum(rng.normal(0.15, 0.6, 24))  # a series, 24 periods
lo, hi = v.min(), v.max()
invite = lo <= 0 or lo < 1.5 * (hi - lo)  # is zero in the neighborhood?
print(f"The data range from {lo:.1f} to {hi:.1f}: "
      + ("zero is in the neighborhood, so include it" if invite
         else "zero is far away, so keep the zoomed axis"))

fig, ax = plt.subplots(1, 2, figsize=(9, 4))
for a, title in zip(ax, ["Zoomed axis", "Axis including zero"]):
    a.plot(np.arange(1, 25), v, "o-", color="#2166ac")
    a.set_title(title)
    a.set_xlabel("Period")
ax[1].set_ylim(min(0, lo), hi * 1.05)
plt.show()

Key takeaways

  • Include zero on the axis when it’s close to the data. It shows proportion.
  • Don’t force zero in when it’s far away. It hides variation.
  • Choose axes on purpose. Software defaults aren’t decisions.

Source

Back to top