MATH 2 • STATISTICS & PROBABILITY

Segmented Bar Charts — I can represent categorical associations with segmented bar charts and interpret comparisons.

Visualize how categories relate by stacking proportions inside a single bar.

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.

1786
William Playfair Invents the Bar Chart
Scottish engineer William Playfair published The Commercial and Political Atlas, introducing the world's first bar charts and line graphs to represent economic data visually.
1858
Florence Nightingale's Polar Area Diagrams
Nightingale used segmented diagrams to show causes of soldier mortality during the Crimean War, demonstrating that stacked visual comparisons could drive policy change.
1900s
Stacked Charts Enter Textbooks
As statistics courses grew in universities, segmented and 100% stacked bar charts became standard tools for displaying categorical associations in social science research.
2000s
Digital Data Visualization
Software like Excel, Google Sheets, and open-source libraries such as D3.js made segmented bar charts accessible to everyone, from students to professional analysts.

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.

1

Categorical Variable

A variable whose values are group labels (e.g., "Yes" or "No", "Red", "Blue", "Green"). You count how many observations fall in each category rather than calculating an average.
2

Two-Way Frequency Table

A table that cross-tabulates counts for two categorical variables. Rows represent one variable and columns represent the other. Totals appear in the margins.
3

Segmented Bar Chart

A bar chart in which each bar is divided into colored segments representing the categories of a second variable. The segments can show raw counts or relative percentages.
4

100% Stacked Bar Chart

A special segmented bar chart where every bar is scaled to the same total height (100%). This makes it easy to compare proportions across groups, even when group sizes differ.
5

Association

Two categorical variables are associated if the distribution of one variable changes depending on the value of the other. If the segments look roughly the same across all bars, there is little or no association.
KEY TAKEAWAY
Think of a segmented bar chart like a row of stacked smoothie cups. Each cup represents a group (say, a grade level), and the colored layers inside represent different flavors (categories of a second variable). If every cup has roughly the same ratio of strawberry to mango to blueberry, the two variables are not associated. But if one cup is mostly strawberry while another is mostly blueberry, those differences suggest an association between group and flavor preference.

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.

Each bar represents one grade level scaled to 100%. Notice how the Sports segment (cyan) shrinks from 9th to 12th grade, while the Music segment (violet) grows. This difference in segment proportions indicates an association between grade level and activity preference.

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.

RELATIVE FREQUENCY (WITHIN A GROUP)
Relative Frequency = (Category Count ÷ Group Total) × 100%
Category Count = the number of observations in a specific category within a group. Group Total = the total number of observations in that group. This converts raw counts to percentages that sum to 100% for each bar.
JOINT RELATIVE FREQUENCY
Joint Relative Frequency = (Cell Count ÷ Grand Total) × 100%
Cell Count = the number of observations in one specific combination of both variables. Grand Total = the total number of all observations. This tells you what percentage of the entire data set falls in that cell.
CONDITIONAL RELATIVE FREQUENCY
Conditional Relative Frequency = (Cell Count ÷ Row or Column Total) × 100%
This is the formula you actually use to compute segment heights in a 100% segmented bar chart. You divide by the row total (or column total) depending on which variable defines your bars.
💡 Why 100% Stacking Matters
If your groups have very different sizes — say 80 students in 9th grade but only 30 in 12th — comparing raw count bars would be misleading. The 9th-grade bar would simply be taller because there are more students. Converting to percentages (conditional relative frequencies) eliminates the effect of unequal group sizes and lets you focus on proportional differences instead.

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.

Two-Way Frequency Table: Transportation Mode by Area Type
CarBusWalkTotal
Urban204040100
Suburban503020100
Total707060200
The Urban bar shows that walking and bus usage dominate (40% each), while the Suburban bar is driven by car usage (50%). The segments are visibly different, indicating an association between area type and transportation mode.

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.

Two-Way Table: Book Preference by Gender Identity
FictionNonfictionTotal
Male203050
Female452570
Non-binary151530
Constructing and Interpreting a 100% Segmented Bar Chart
1
Step 1 — Compute Conditional Relative FrequenciesDivide each cell by its row total and multiply by 100. For Male: Fiction = 20 ÷ 50 × 100 = 40%, Nonfiction = 30 ÷ 50 × 100 = 60%. For Female: Fiction = 45 ÷ 70 × 100 ≈ 64.3%, Nonfiction = 25 ÷ 70 × 100 ≈ 35.7%. For Non-binary: Fiction = 15 ÷ 30 × 100 = 50%, Nonfiction = 15 ÷ 30 × 100 = 50%.
Male: 40% Fiction / 60% Nonfiction | Female: 64.3% Fiction / 35.7% Nonfiction | Non-binary: 50% / 50%
2
Step 2 — Draw the BarsCreate three bars of equal total height (each representing 100%). Label them Male, Female, and Non-binary on the horizontal axis. Shade the Fiction portion in one color (e.g., violet) and the Nonfiction portion in another (e.g., amber). The height of each colored section corresponds to the percentages you just calculated.
3
Step 3 — Add Labels and a LegendWrite the percentage value inside each segment (or next to it if the segment is narrow). Include a legend identifying which color represents Fiction and which represents Nonfiction. Add axis labels for the group variable (gender identity) and the percentage scale.
4
Step 4 — Interpret the ChartCompare the Fiction segments across the three bars. Males show 40% Fiction, Non-binary shows 50%, and Females show about 64%. Because the proportions vary noticeably from one group to another, there appears to be an association between gender identity and book preference in this sample. Females are more likely to prefer fiction, while males lean toward nonfiction. If all three bars had the same proportions, we would conclude there is no association.
There IS an association — the distribution of book preference changes across gender identity groups.

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.

When to Use (and Not Use) Segmented Bar Charts
FeatureStrengthLimitation
Comparing proportions100% 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 categoriesWorks well with 2–4 categories in the stacked variable.With 5+ segments, the middle segments float and become difficult to compare precisely.
Showing totalsCount-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 barsSegmented bars use less horizontal space than grouped bars.Side-by-side bars let you compare individual category heights more accurately.
🎯 CHOOSING THE RIGHT CHART
Use a 100% segmented bar chart when your main goal is to compare the relative distribution of a categorical variable across groups. If you need to compare exact counts or have many small categories, a grouped bar chart or a data table might be clearer.

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.

From Visual Exploration to Formal Inference
ConceptWhat You Learn NowWhat Comes Later
Detecting associationVisually 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 distributionsCompute 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 plotsEach 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

PROBLEM 1CONCEPTUAL
You create a 100% segmented bar chart comparing phone brand preference (Apple, Samsung, Other) across two age groups (Under 18, 18+). The two bars look almost identical in their segment proportions. What does this tell you about the relationship between age group and phone brand preference?
PROBLEM 2BASIC CALCULATION
A two-way table shows that 24 out of 60 sophomores prefer comedy movies, while 36 prefer action movies. Calculate the conditional relative frequency for each genre and describe what the two segments of a 100% bar for sophomores would look like.
PROBLEM 3INTERMEDIATE
A survey of 180 students records exercise frequency (Regular, Occasional, Never) and grade level (Freshman, Senior). The data: Freshmen — Regular: 15, Occasional: 30, Never: 45 (total 90). Seniors — Regular: 36, Occasional: 36, Never: 18 (total 90). Compute the conditional relative frequencies for each group and explain whether there appears to be an association.
PROBLEM 4APPLIED
A marketing team surveys 400 customers at two store locations (Mall, Downtown) about payment method (Cash, Credit Card, Mobile Pay). Mall: Cash 40, Credit 100, Mobile 60 (total 200). Downtown: Cash 80, Credit 60, Mobile 60 (total 200). The team builds a 100% segmented bar chart. A manager claims the chart proves that Mall customers prefer credit cards more than Downtown customers do. Is this interpretation valid? Explain using the conditional relative frequencies.
PROBLEM 5CRITICAL THINKING
A student creates a count-based (not percentage-based) segmented bar chart for pet preference (Dog, Cat, Fish) across three schools. School A has 500 students surveyed, School B has 100, and School C has 50. The student concludes that School A students like dogs the most because the dog segment in School A's bar is the tallest. Critique this conclusion and explain how a 100% segmented bar chart would lead to a more valid comparison.

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.

Varsity Tutors • Math 2 • Segmented Bar Charts