Visualization VocabularyDataviz vocabulary
Diagram: surplus-deficit filled line
Drawing: Adrien Taudière (CC0)
ggplot2 example: surplus-deficit filled line
Adrien Taudière (CC0); R code ↓; data: gapminder (Bryan 2025) (CC BY 4.0)

chart

surplus-deficit filled line

Line whose area is filled either side of a baseline to contrast surplus and deficit.

Classification

Channels

Attestation

Scientific literature

OpenAlex: 0 papers

Seminal references

R packages

R code of the ggplot2 example

library(ggplot2)
library(dplyr)
library(gapminder)

## China's gap to the unweighted mean of the 142 countries, every five years.
gap <- gapminder |>
  group_by(year) |>
  mutate(gap = lifeExp - mean(lifeExp)) |>
  ungroup() |>
  filter(country == "China")
## Interpolated every month, so that each fill stops where the line crosses 0.
fine <- as_tibble(approx(gap$year, gap$gap, n = 661)) |>
  rename(year = x, gap = y)

p <- ggplot(fine, aes(x = year)) +
  geom_ribbon(aes(ymin = 0, ymax = pmax(gap, 0)), fill = "#2e7891", alpha = 0.35) +
  geom_ribbon(aes(ymin = pmin(gap, 0), ymax = 0), fill = "#dc863b", alpha = 0.35) +
  geom_hline(yintercept = 0, colour = "#535353", linewidth = 0.4) +
  geom_line(aes(y = gap), linewidth = 0.6, colour = "#535353") +
  annotate("text", x = 1990, y = 2.2, label = "Above the mean", colour = "#2e7891", size = 3.2) +
  annotate("text", x = 1952.5, y = -7.5, label = "Below", colour = "#c06a1f", hjust = 0, size = 3.2) +
  scale_x_continuous(breaks = seq(1952, 2007, by = 10), expand = expansion(mult = 0.01)) +
  scale_y_continuous(labels = lex_number) +
  labs(title = "China's life expectancy has stayed above the mean since 1967",
       subtitle = "Gap to the mean of 142 countries, in years of life expectancy at birth",
       x = NULL, y = "Gap (years)",
       caption = "Data: Gapminder, via the gapminder R package") +
  theme_lex_viz(grid = "y", arrows = "y")

Sources (1)

Cite this entry

Stable addresshttps://dataviz.adrientaudiere.com/en-only/term/surplus-deficit-filled-line.html

ReferenceTaudière Adrien. 2026. surplus-deficit filled line. In Visualization Vocabulary, version 1.0.0. IdEst. https://dataviz.adrientaudiere.com/en-only/term/surplus-deficit-filled-line.html

BibTeX
@incollection{taudiere2026-surplus-deficit-filled-line,
  author    = {Taudière, Adrien},
  title     = {surplus-deficit filled line},
  booktitle = {Visualization Vocabulary},
  year      = {2026},
  version   = {1.0.0},
  publisher = {IdEst},
  url       = {https://dataviz.adrientaudiere.com/en-only/term/surplus-deficit-filled-line.html},
  note      = {CC0 1.0}
}

Page created on 2026-10-13. Text last changed on 2026-11-12. Images last changed on 2026-11-02. Numbers computed on 2026-10-22.