Stacked bar chart

On this page 7

A stacked bar chart is a bar chart in which each bar is divided into segments that represent subcategories, so that the full bar length shows a category total and each segment shows that subcategory’s contribution to the total. In data visualization, it answers two questions at once: how large each category is, and what it is made of.

The form is common in business reporting, survey analysis and operational dashboards. Its strength is part-to-whole comparison across several categories; its main weakness is that only the bottom segment shares a common baseline, which makes the other segments hard to compare precisely.

How a stacked bar chart encodes data

A stacked bar chart maps each category to a bar and each series to a colored segment placed end to end along the value axis. The length of a segment encodes its value, its color encodes the series, and the combined length encodes the sum. Bars can run vertically, often called a stacked column chart, or horizontally, which suits long category labels.

Perception research on graphical encoding ranks position along a common scale as the most accurate visual channel and length without a common baseline as less accurate. In a stacked bar, the first segment and the total sit on the shared baseline, while every middle segment floats. Readers therefore judge totals and the bottom series well, but middle segments poorly.

The following table summarizes what each visual element carries and how reliably viewers read it.

ElementEncodesReading accuracy
Total bar lengthCategory sumHigh, common baseline
First segmentBaseline series valueHigh, common baseline
Middle segmentsOther series valuesLow, floating start points
Segment colorSeries identityDepends on palette and legend
Bar orderCategory sequence or rankHigh when sorted meaningfully
Visual elements of a stacked bar chart

Absolute, percentage and diverging variants

Stacked bar charts come in three main variants that suit different questions. The absolute stacked bar shows raw values, so bar lengths differ. The 100% stacked bar, also called a percentage stacked bar, normalizes every bar to the same length and shows shares rather than amounts. The diverging stacked bar centers the bars on a midpoint, which is the preferred form for Likert-scale survey results.

VariantShowsBest forLoses
Absolute stackedTotals and parts in unitsRevenue by region and productPrecise comparison of upper segments
100% stackedComposition as sharesMarket share, channel mixInformation about totals
Diverging stackedNegative and positive sides of a midpointAgree and disagree survey scalesSimple reading of totals
Grouped barParts side by side, not stackedComparing individual seriesDirect view of totals
Main variants and when each applies

A 100% stacked bar should be labeled clearly as percentages, and the underlying sample size of each bar should be shown, because equal bar lengths hide very different totals.

Several neighboring chart types show part-to-whole relationships, and the right choice depends on how many categories, how many parts and whether time is involved. A pie chart or donut chart shows composition for a single whole, an area chart shows composition over a continuous time axis, and a treemap handles hierarchical parts at many levels.

ChartNumber of wholesStrengthWeakness
Stacked bar chartSeveral categoriesTotals and composition togetherMiddle segments hard to compare
Pie or donut chartOneInstant share of a single wholeAngles compare poorly
Stacked area chartContinuous time seriesShows trends in compositionUpper layers distort visually
TreemapOne hierarchyMany nested partsArea judged less accurately than length
Small multiplesManyEach series on its own baselineUses more space
Choosing between part-to-whole charts

Design practices for readable stacked bars

Good design compensates for the chart’s weak points. The most useful rule is to place the most important series at the baseline, since only that series is read accurately. Categories should be sorted by total or by a meaningful order, not alphabetically, unless the audience needs to look up a specific label.

  • Limit segments to about five; beyond that, merge small series into an Other group.
  • Keep segment order and colors identical across all bars and related charts.
  • Use a sequential palette for ordered series and a categorical palette for unordered ones, with sufficient contrast for color-blind readers.
  • Label segments directly when space allows, which removes the need to match colors to a legend.
  • Start the value axis at zero, because truncated axes distort both totals and segment lengths.

Libraries such as Matplotlib, D3.js and most business intelligence tools support stacking through a single option, but defaults often order segments by data order and assign colors arbitrarily, so manual configuration is usually required.

Interactive versions add value through tooltips that show exact segment values and through legends that let viewers isolate one series. Isolating a series temporarily moves it to the baseline, which turns a hard length judgment into an accurate position judgment.

Limitations and common misreadings

The chart becomes misleading when it is used for a question it cannot answer well. Asking viewers to compare a middle segment across bars produces slow and inaccurate judgments, and negative values break the stacking logic unless a diverging layout is used.

ProblemCauseFix
Viewers misjudge a middle seriesNo common baselineMove it to the bottom or use small multiples
Rainbow of thin sliversToo many seriesGroup minor series as Other
Totals misread in 100% chartsNormalization hides sizeAdd totals or sample sizes
Negative values overlapMixed signs in one stackUse a diverging stacked bar
Common problems and fixes

Put simply

Picture a row of glass jars, each holding layers of different colored sand. The height of each jar shows how much sand it holds in total, and the colored layers show what the total is made of. A stacked bar chart works the same way, with bars instead of jars.

It is easy to see which jar is fullest and how thick the bottom layer is. Layers in the middle are harder to compare, because they start at different heights. That is why the most important layer belongs at the bottom.

In practice

A regional hospital network reports monthly emergency department visits for its four sites. An analyst builds a horizontal stacked bar chart with one bar per site and three segments: walk-in patients, ambulance arrivals and referrals. Ambulance arrivals sit at the baseline because the board’s question concerns ambulance capacity.

The chart shows at a glance that the largest site handles about 6,200 visits a month, and that ambulance arrivals account for nearly 40 percent there, compared with roughly 20 percent at the other sites. A second, 100% stacked version placed alongside makes that share difference explicit. The board uses the pair of charts to approve an additional ambulance bay at the busiest site.