Stacked Bar Chart
Stacked bar charts are a powerful tool for visualizing data with multiple categories. They allow you to compare totals across groups while also seeing the breakdown of each group's components. This guide will walk you through everything you need to know to master them.

What Is a Stacked Bar Chart?
A stacked bar chart is a type of graph that uses rectangular bars, divided into segments, to represent and compare parts of a whole across different categories. Each bar represents a total amount for a specific category, and the segments within that bar show the contribution of various subcategories to that total. The length or height of the entire bar corresponds to the aggregate value, while the length of each segment represents the value of its respective subcategory.
Think of it as a series of individual bar charts stacked on top of one another. This visualization is incredibly useful for understanding the composition of data. Let's break down its key components:
- The Axes: Like most charts, a stacked bar chart has two axes. The horizontal axis (or x-axis) typically displays the distinct categories you are comparing (e.g., years, countries, different groups). The vertical axis (or y-axis) is a numerical scale that measures the value of the data (e.g., population, sales figures, number of students).
- The Bars: Each bar corresponds to one of the main categories on the x-axis. The total height of the bar represents the total value for that category.
- The Segments: Each bar is divided into several smaller rectangular segments. These segments are color-coded to represent different subcategories. The size of a segment is proportional to its value within the total for that bar.
- The Legend: The legend, or key, is crucial for understanding the chart. It tells you which color corresponds to which subcategory, allowing you to identify the different segments within each bar.
A stacked bar chart differs from a simple bar chart, which only shows totals, and a grouped bar chart, which places bars for subcategories side-by-side instead of on top of each other. The stacking feature uniquely emphasizes the part-to-whole relationship within each category.
When Should You Use a Stacked Bar Chart?
Stacked bar charts are not a one-size-fits-all solution. They shine in specific scenarios where you need to convey a particular kind of story with your data. The primary reason to choose a stacked bar chart is when you want to show a part-to-whole relationship while also comparing totals across several categories.
Here are some ideal situations for using a stacked bar chart:
- Comparing Composition Over Time: Imagine you want to track a company's revenue from different product lines (e.g., laptops, phones, accessories) over several years. A stacked bar chart would show not only if the total revenue is growing each year but also how the contribution of each product line to that total is changing.
- Analyzing Survey Results: When you survey a group of people and want to break down the responses by demographic, a stacked bar chart is perfect. For example, you could have bars for different age groups, with segments showing their answers (e.g., 'Agree', 'Disagree', 'Neutral').
- Budget or Expense Breakdowns: You can use a stacked bar chart to compare the monthly expenses of different households. Each bar is a household, and the segments could be categories like 'Rent', 'Food', 'Utilities', and 'Entertainment'. This allows for a quick comparison of both total spending and spending habits.
- Market Share Analysis: To show how market share is divided among competitors in different regions, each bar can represent a region, and the segments can represent the market share percentage of each company. This would be a 100% stacked bar chart, which we'll cover later.
The key takeaway is to use a stacked bar chart when your message involves both comparing the overall totals and understanding the internal composition of those totals. If you only care about comparing totals, a simple bar chart is better. If you want to compare subcategories against each other directly, a grouped bar chart is often clearer.
How to Read a Stacked Bar Chart
Reading a stacked bar chart effectively requires a systematic approach. It's easy to get lost in the colors and segments, but following these steps will help you extract meaningful information accurately.
- Start with the Basics: First, read the chart's title to understand its overall purpose. Then, examine the x-axis to see what main categories are being compared and the y-axis to understand the unit of measurement and its scale.
- Consult the Legend: The legend is your map to the chart. Identify which color corresponds to each subcategory. This is essential before you try to interpret any of the bars.
- Compare the Totals: Before diving into the segments, look at the total height of each bar. This gives you a high-level comparison of the aggregate values for each main category. Which bar is the tallest? Which is the shortest? This tells you which category has the highest and lowest total value.
- Analyze the Segments: Now, look at the individual colored segments within each bar. Start with the bottom segment. Because all the bottom segments share the same baseline (the x-axis, at y=
), they are easy to compare directly across the bars. For all other segments, you must judge their size by their length, not by their position on the y-axis. To find the exact value of a segment that isn't at the bottom, you must take the value at its top edge and subtract the value at its bottom edge.
A survey asked students at two high schools, North High and South High, about their favorite after-school activity. The results are shown in the stacked bar chart below.
(Imagine a chart with two bars. 'North High' bar has a 'Sports' segment from 0 to 60, a 'Clubs' segment from 60 to 90, and a 'Gaming' segment from 90 to 120. 'South High' bar has a 'Sports' segment from 0 to 50, a 'Clubs' segment from 50 to 105, and a 'Gaming' segment from 105 to 150.)
Let's interpret this chart:
- Totals: The 'South High' bar is taller (total
students) than the 'North High' bar (total students). This means more students were surveyed at South High. - Bottom Segment (Sports): Looking at the bottom blue segment, we can easily compare participation in 'Sports'. North High has
students, while South High has . More students at North High chose sports. - Middle Segment (Clubs): For 'Clubs' (the middle orange segment), we can't just look at the y-axis value. For North High, the segment goes from
to , so its value is students. For South High, it goes from to , so its value is students. South High has more students in clubs. - Top Segment (Gaming): For 'Gaming' (the top green segment), North High's segment goes from
to , a value of students. South High's goes from to , a value of students.
Conclusion: While North High had more students prefer sports, South High had a greater number of students prefer clubs and gaming, and also had more students surveyed overall.
Creating a Stacked Bar Chart: A Step-by-Step Guide
Building your own stacked bar chart is a great way to understand how they work. It's a straightforward process that starts with organizing your data correctly.
Step 1: Gather and Organize Your Data
Your data should be in a table format, with main categories in one column and the values for your subcategories in subsequent columns.
Let's say we want to visualize the quarterly revenue for a small business, broken down by Online and In-Store sales.
Raw Data Table:
| Quarter | Online Revenue ($) | In-Store Revenue ($) |
|---|---|---|
| Q1 | ||
| Q2 | ||
| Q3 | ||
| Q4 |
Step 2: Calculate Totals and Cumulative Values
To stack the bars, you need to know the total height of each bar and where each segment begins and ends. It's helpful to create a new table with cumulative values. Let's decide to put 'Online Revenue' at the bottom of our bars.
Calculation Table:
| Quarter | Online Revenue (Segment 1) | In-Store Revenue (Segment 2) | Total Revenue (Bar Height) |
|---|---|---|---|
| Q1 | Value: | Value: | |
| Q2 | Value: | Value: | |
| Q3 | Value: | Value: | |
| Q4 | Value: | Value: |
Step 3: Set Up Your Axes and Draw the Chart
1. Draw your x-axis and y-axis. Label the x-axis 'Quarter' and create tick marks for Q1, Q2, Q3, and Q4.
2. Label the y-axis 'Revenue ($)'. Choose a scale that accommodates your highest total value (
3. For each quarter, draw the first segment. For Q1, draw a bar for 'Online Revenue' up to
4. Stack the next segment on top. For Q1, the 'In-Store Revenue' segment starts where the online one ended (at
5. Repeat this process for all other quarters.
6. Create a legend that assigns a color to 'Online Revenue' and another to 'In-Store Revenue'.
Let's fully work through the creation of the chart for the Q1 data from above.
- Axes Setup: X-axis has 'Q1', 'Q2', 'Q3', 'Q4'. Y-axis is scaled from
to . - Draw Q1 Bar: Our main category is 'Q1'.
- First Segment (Online): The value is
. Draw a rectangle above 'Q1' that goes from to . Let's color this blue. - Second Segment (In-Store): The value is
. This segment starts at the top of the previous one ( ). Its height is , so it ends at . Draw a rectangle from to . Let's color this orange. - Final Touches: The total height of the bar for Q1 is
. Create a legend: Blue = Online Revenue, Orange = In-Store Revenue. Now, repeat for the other quarters to complete the chart.
Standard vs. 100% Stacked Bar Charts
There are two main types of stacked bar charts: the standard one we've been discussing, and the 100% stacked bar chart. While they look similar, they answer very different questions.
Standard Stacked Bar Chart
This chart uses absolute values. The height of each bar represents the actual total for its category. This type is best when you want to:
- Compare the total values between categories.
- See the absolute contribution of each subcategory.
Its main limitation is that if the totals vary wildly, it can be hard to compare the composition of a very short bar to that of a very tall bar.
100% Stacked Bar Chart
This chart displays the relative proportion of each subcategory, where the total for every bar is normalized to
- Compare the proportional composition of different categories.
- See if the relative balance of subcategories changes, regardless of changes in the total.
The major trade-off is that you lose the ability to see the actual total values. A bar representing
Let's convert our business revenue data from Example 2 into a 100% stacked bar chart to focus on the changing business model.
Step 1: Calculate Percentages
We use the formula above for each subcategory in each quarter.
- Q1: Total =
. Online: . In-Store: . - Q2: Total =
. Online: . In-Store: . - Q3: Total =
. Online: . In-Store: . - Q4: Total =
. Online: . In-Store: .
Step 2: Draw the Chart
The x-axis remains the same (Quarters). The y-axis now goes from
For Q1, the 'Online' segment goes from
For Q4, the 'Online' segment goes from
This chart clearly shows that while total revenue was growing, the proportion of revenue from online sales was also increasing significantly each quarter.
Common Mistakes and Pitfalls to Avoid
Stacked bar charts are powerful, but they can also be misleading if not designed carefully. Here are some common mistakes to watch out for when you're creating or interpreting them.
- Too Many Segments: This is the most common pitfall. When you try to stack too many subcategories (generally more than
or ), the bar becomes a cluttered 'rainbow' that is impossible to read. The segments become too thin to compare, defeating the purpose of the chart. If you have many subcategories, consider grouping smaller ones into an 'Other' category. - Misinterpreting Segment Sizes: Remember, only the bottom-most segment in each bar shares a common baseline. It's a frequent mistake to visually compare the top edge of two middle segments on the y-axis. You must always evaluate a segment by its length (top value minus bottom value), not its position.
- Inappropriate Use of Color: Color is key to distinguishing segments. Using colors that are too similar makes the chart hard to decipher. Conversely, using a random assortment of bright colors can be distracting. It's best to use a logical color palette, such as different shades of one color (sequential) or distinct, easily distinguishable colors (categorical).
- Forgetting the Legend: A stacked bar chart is completely meaningless without a legend to explain what each color represents. Always ensure your legend is clear and visible.
- Ordering Segments Inconsistently: For readability, the order of the segments should be the same in every bar. For example, if 'Online Sales' is the bottom segment in the first bar, it should be the bottom segment in all bars. This creates a more stable visual flow.
- Using for Data That Isn't Part-to-Whole: The core strength of this chart is showing composition. If your subcategories don't add up to a meaningful total (e.g., comparing the number of apples, oranges, and cars sold by a store), then a stacked bar chart is the wrong choice. A grouped bar chart would be far more appropriate.
Quick Summary and Key Takeaways
This lesson covered the essentials of understanding, creating, and interpreting stacked bar charts. Here are the most important points to remember:
- Primary Purpose: Use a stacked bar chart to compare the total values across several main categories while simultaneously showing the composition (the part-to-whole relationship) of each of those totals.
- Key Components: A stacked bar chart consists of an x-axis for categories, a y-axis for numerical values, bars representing category totals, color-coded segments representing subcategories, and a legend to decode the colors.
- How to Read: First, compare the total heights of the bars to understand the overall picture. Then, use the legend to analyze the segments. Remember that only the bottom segments are directly comparable; others must be measured by their length.
- Two Main Types:
1. Standard Stacked Bar Chart: Shows absolute values and allows for comparison of both totals and segment values.
2. 100% Stacked Bar Chart: Shows relative percentages, making all bars the same height. It's ideal for comparing the proportional makeup of categories, but it hides the absolute total values. - Best Practices: Avoid using too many segments (keep it under
), choose colors wisely, order your segments consistently, and always include a clear legend. Ensure your data truly represents a part-to-whole relationship before choosing this chart type.
Frequently Asked Questions
What's the main difference between a stacked and a grouped bar chart?
A stacked bar chart places subcategory values on top of each other within a single bar to show how they contribute to a total. A grouped bar chart places the bars for subcategories side-by-side, making it easier to compare the subcategories directly with each other but harder to see the total for the main category.
Can you have negative values in a stacked bar chart?
It is possible but generally not recommended as it makes the chart very complex and difficult to read. A chart with both positive and negative values would need a baseline at y=0, with segments stacking up for positive values and down for negative values. This is an advanced use case and can often be better represented by a different chart type, like a waterfall chart.
How many categories are too many for a stacked bar chart?
For the segments within a single bar, it's best to stick to 5 or fewer. Any more and the chart becomes cluttered and hard to read. For the main categories along the x-axis, there's more flexibility, but if you have more than 10-12 bars, the chart can become too wide and lose its impact.
Is a stacked bar chart the same as a pie chart?
No, but they are related. Both show part-to-whole relationships. A single bar in a stacked bar chart is like a pie chart straightened out into a rectangle. The advantage of a stacked bar chart is that you can compare the composition of multiple 'pies' (or bars) at once.
Why is it hard to compare segments that aren't on the bottom?
Segments that are not at the bottom do not share a common starting point or baseline. Your eyes have to mentally isolate each segment and judge its length, which is much harder than comparing segments that all start at the same y-value of 0. This makes precise visual comparison difficult for the upper segments.
When is a 100% stacked bar chart better than a standard one?
A 100% stacked bar chart is better when your primary goal is to compare the proportions or percentages of subcategories across different groups, and the absolute totals are not important. It standardizes the bars, making it very easy to see shifts in composition, like a change in market share over time.
What kind of data is needed to make a stacked bar chart?
You need categorical data and numerical data. You need one set of main categories for the x-axis (e.g., years, locations) and several numerical subcategories for the segments (e.g., sales figures for Product A, Product B, Product C). Crucially, the subcategories should be parts that add up to a meaningful whole.