# Back-to-back bars

> Use back-to-back bars (a population pyramid) to compare two groups across the same ordered categories, mirrored on a shared spine.

- Data type: Values per item (`compare`)
- Free (MIT): install with `npx chartreuse add back-to-back-bars`, or registry item `/r/back-to-back-bars.json`
- Example: **Japan has three times as many people over 80 as under 5; Nigeria is its mirror image** (People by five-year age group and sex, 2023; switch between Japan and Nigeria)
- How to read it: Men extend left and women right from the age labels in the middle, youngest at the bottom; each country has its own scale.
- Phone: Adapts to mobile (Draws its own phone layout below 520px) · Video formats: 16:9, 9:16 (best 9:16)

## Use it when
- two groups share the same ordered categories (ages, income bands, survey answers)
- the shape of each side tells the story
- comparing the two sides row by row

## Avoid it when
- more than two groups
- the categories have no order
- the exact difference between sides matters most (plot the difference)

## Fields (data.json)
- `Japan` (id): one group's list of { age, men, women }, first row at the bottom (Japan in the example; any names, one chip each)
- `Nigeria` (id): another group's list of { age, men, women } (Nigeria in the example)
- `age` (category): the ordered row (a five-year age group in the example)
- `men` (number, unit "people", format count): the left side's value (men in the example, people); its name is hints.sides[0]
- `women` (number, unit "people", format count): the right side's value (women in the example, people); its name is hints.sides[1]

Units are the example's: with your own data, set each number field's `unit` and `format` (percent, count, decimal, currency, compact) in the meta you pass to mount, or `chartreuse render --unit field=text --format field=count`. Scales and labels follow your data.

## Interactions, motion, sound
- hover or tap a row to read both sides and its share of everyone
- the country chips switch the pyramid
- Motion: Bars grow out from the spine, youngest first; switching country reshapes the pyramid in place.
- Sound: A whoosh when the country changes; a pop pitched by age on hover. Quiet while it draws and between steps; mute it from its card. (sound is off until the viewer turns it on)

## Example spec
```json
{
  "chart": "back-to-back-bars",
  "title": "Japan has three times as many people over 80 as under 5; Nigeria is its mirror image",
  "subtitle": "People by five-year age group and sex, 2023; switch between Japan and Nigeria",
  "data": "/charts/back-to-back-bars.data.json"
}
```

## Source
World Development Indicators: population by five-year age group and sex (SP.POP.xxxx.MA.5Y, SP.POP.xxxx.FE.5Y) and total population by sex, World Bank (from UN World Population Prospects) (CC BY 4.0), retrieved 2026-12-01: https://data.worldbank.org/indicator/SP.POP.0004.FE.5Y

Note: Counts are the World Bank's share of each age group times the total by sex, so they are rounded estimates.

Live: /charts/back-to-back-bars · Manifest: /charts/back-to-back-bars.json · Tags: population pyramid, back to back, butterfly chart, mirror, age, population, demography
