Population Pyramid (Mirrored Butterfly Chart)
Centered diverging demographic pyramid chart comparing two groups side-by-side using mirrored horizontal bar stacks.
◆Mirrored Diverging Stacks with stackOffset='sign'
Supply negative numbers for the left cohort and positive numbers for the right cohort inside <BarChart layout='vertical' stackOffset='sign'>.
<BarChart layout="vertical" data={data} stackOffset="sign">
<ReferenceLine x={0} stroke="#2a3038" strokeWidth={2} />
<Bar dataKey="frontend" fill="#00e5a0" radius={[4, 0, 0, 4]} barSize={18} />
<Bar dataKey="backend" fill="#4a9eff" radius={[0, 4, 4, 0]} barSize={18} />
</BarChart>◆Displaying Positive Absolute Values on X-Axis
Format the numerical X-axis using Math.abs(v) so users see clean positive count magnitudes on both sides of the center divider.
tickFormatter={(v) => `${Math.abs(v) / 1000}k`}A Population Pyramid (Mirrored Butterfly Chart) is ideal for developers and designers who need to display data clearly and effectively. Use this chart type when:
- ✓Comparing values across multiple categories (e.g. monthly revenue per region)
- ✓Showing ranked data where order matters (e.g. top 10 products by sales)
- ✓Displaying survey results or poll responses
- ✓Visualizing before/after comparisons
What is a population pyramid (butterfly chart)?
A population pyramid (also known as a butterfly chart or mirrored bar chart) consists of two back-to-back horizontal bar charts sharing a central vertical category axis. It is traditionally used to display age and gender distribution in demography, or mirrored comparative metrics.
How do you make a population pyramid in Recharts (mirrored bar chart recharts)?
Configure <BarChart layout='vertical' stackOffset='sign'>. Store the left-side series as negative numerical values (-10, -50) so Recharts stacks them to the left, and use tickFormatter={(v) => Math.abs(v)} on the X-axis so users see positive counts on both sides.
What are common business use cases for a butterfly chart?
Beyond demographics, butterfly charts are ideal for Inflow vs Outflow cashflow comparisons, Mobile vs Desktop conversion funnels, and Positive vs Negative customer feedback volume by product line.