Historical Context & Motivation
Long before spreadsheets and software existed, statisticians needed ways to show how different groups compared across categories. A simple bar chart can show how many people prefer dogs versus cats, but what if you also want to see how that preference breaks down by age group or by region? That is the kind of question that led to the development of segmented bar charts, also called stacked bar charts. These charts layer segments inside a single bar so you can compare proportions across groups at a glance.
The central question that segmented bar charts address is: Is there an association between two categorical variables? When you look at a regular bar chart, you see counts or values for one variable. A segmented bar chart adds a second dimension, letting you compare the internal composition of each bar. This makes it much easier to spot patterns, trends, and differences across groups.
Core Principles & Definitions
Before building a segmented bar chart, you need to understand a few foundational ideas. A categorical variable is a variable that places data into groups or categories rather than measuring a numerical quantity. Examples include favorite color, grade level, or type of transportation. When you have two categorical variables and want to explore how they relate, you organize the data in a two-way frequency table and then translate it into a segmented bar chart.
Categorical Variable
Two-Way Frequency Table
Segmented Bar Chart
100% Stacked Bar Chart
Association
Visual Explanation
The diagram below shows a 100% segmented bar chart based on a survey of 200 high-school students. Students were asked about their preferred after-school activity, and the results are broken down by grade level (9th, 10th, 11th, and 12th). Each bar reaches the same height — 100% — so you can directly compare the proportions of each activity across grades.
When you interpret a segmented bar chart, start by comparing the same colored segment across all bars. If one segment consistently changes in size from one bar to the next, that pattern signals an association between the two variables. In the chart above, younger students lean toward Sports while older students shift toward Music. If every bar looked nearly identical, you would conclude that grade level and activity preference are not associated.
Mathematical Framework
The mathematics behind a segmented bar chart is straightforward: you convert raw frequency counts into relative frequencies (percentages) within each group. Here are the key formulas you will use.
Step-by-Step: From Data Table to Chart
Let's walk through the full process of creating a segmented bar chart using a real-style data set. Suppose a school surveys 200 students about their preferred mode of transportation to school (Car, Bus, Walk), broken down by whether they live in an Urban or Suburban area.
| Car | Bus | Walk | Total | |
|---|---|---|---|---|
| Urban | 20 | 40 | 40 | 100 |
| Suburban | 50 | 30 | 20 | 100 |
| Total | 70 | 70 | 60 | 200 |
Notice how the Urban and Suburban bars have clearly different compositions. Urban students are much more likely to walk or ride the bus, while Suburban students rely more heavily on cars. Because the segment proportions change from one bar to the next, we say there is an association between area type and transportation mode. If both bars looked identical — say 35% Car, 35% Bus, 30% Walk for both groups — we would say there is no association.
Worked Example
A teacher surveyed 150 students about whether they prefer reading fiction or nonfiction. The results were grouped by gender identity (Male, Female, Non-binary). Use the data to create a 100% segmented bar chart and determine whether there is an association between gender identity and book preference.
| Fiction | Nonfiction | Total | |
|---|---|---|---|
| Male | 20 | 30 | 50 |
| Female | 45 | 25 | 70 |
| Non-binary | 15 | 15 | 30 |
Strengths, Limitations & Comparisons
Segmented bar charts are powerful, but they are not always the best choice. Understanding when to use them — and when another chart type might be clearer — will make you a stronger data communicator.
| Feature | Strength | Limitation |
|---|---|---|
| Comparing proportions | 100% stacked bars make proportional comparisons across groups very intuitive, even with unequal group sizes. | Individual segment sizes can be hard to judge visually when many categories are stacked. |
| Number of categories | Works well with 2–4 categories in the stacked variable. | With 5+ segments, the middle segments float and become difficult to compare precisely. |
| Showing totals | Count-based stacked bars show overall group totals via bar height. | 100% stacked bars hide actual counts — you lose information about group size. |
| Alternative: Side-by-side bars | Segmented bars use less horizontal space than grouped bars. | Side-by-side bars let you compare individual category heights more accurately. |
Connection to Advanced Methods
Segmented bar charts are your visual entry point into a larger statistical question: Are two categorical variables independent or associated? In more advanced statistics courses, you will formalize this question using hypothesis tests. The table below shows how segmented bar charts connect to what comes next.
| Concept | What You Learn Now | What Comes Later |
|---|---|---|
| Detecting association | Visually compare segment proportions across bars in a segmented bar chart. | The chi-square (χ²) test of independence gives a numerical p-value to determine if the visual difference is statistically significant. |
| Conditional distributions | Compute conditional relative frequencies by hand and plot them as segments. | In AP Statistics, you compare observed vs. expected frequencies under the assumption of independence. |
| Mosaic plots | Each bar has the same width (100% stacking focuses on proportions only). | Mosaic plots vary bar widths to also represent group sizes, giving a richer picture of the data. |
Think of a segmented bar chart as the exploratory step: you look at the data and form a hypothesis about association. The chi-square test is the confirmatory step: it tells you whether the pattern you see could easily have occurred by random chance. Building strong chart-reading skills now will make those later techniques much more intuitive.
Practice Problems
Lesson Summary
A segmented bar chart divides each bar into colored segments that represent categories of a second categorical variable. To enable fair comparisons across groups of different sizes, you convert raw counts into conditional relative frequencies and build a 100% stacked bar chart where every bar reaches the same total height.
You detect an association between two categorical variables when the segment proportions differ noticeably from one bar to the next. If all bars have roughly the same composition, the variables appear not associated. This visual approach lays the groundwork for more advanced techniques like the chi-square test of independence, which you will encounter in future statistics courses.