Tabular and Graphical Representations for Two Categorical Variables
Do two groups have the same pattern of choices? Learn to read two-way tables, compare bar charts and mosaic plots, and support an association claim with the right evidence.
By the end of this lesson, you should be able to:
- Read the cells and totals of a two-way table in context.
- Compare side-by-side bar charts, segmented bar charts and mosaic plots.
- Distinguish the number in a category from its share of a group.
- Recognize an association by comparing distributions across groups.
- Justify a claim with labeled evidence and avoid a cause-and-effect overstatement.
Before you start: Know what a categorical variable is and how to read a one-variable bar chart. Review Topic 1.4: Graphs for One Categorical Variable if needed.
First time learning this? Follow the school travel example from its table to each graph. Keep asking what the height, length, width or area represents.
Here to revise? Use the graph-reading checklist, then try the practice questions before opening the solutions.
The concept in 60 seconds
With one categorical variable, we describe how observations are split among categories. With two categorical variables measured on the same individuals, we can ask whether the distribution of one variable changes across categories of the other.
For example, record each student’s grade level and main travel mode. A two-way table keeps both pieces together. A graph then makes it easier to compare travel patterns in Grade 9 and Grade 10.
The key question: within each grade, what share of students use each travel mode? Comparing raw counts alone can be misleading when the grades contain different numbers of students.
of this grade walk.
of this grade walk.
Each track represents of its grade. The walker counts match, but the group proportions do not.
If the category proportions differ across groups, the data show an association. That describes a relationship in the observed data. It does not, by itself, establish that one variable causes the other or that a population relationship has been proved.
A school records grade and travel mode
In an original fictional example, a school records main travel mode for each of participating students. There are Grade 9 students and Grade 10 students. Each student belongs to : bus, walk or car ride.
| Grade level | Bus | Walk | Car ride | Row total |
|---|---|---|---|---|
| Grade 9 | ||||
| Grade 10 | ||||
| Column total |
Two-way table
A table showing combinations of categories for two categorical variables. It is also called a contingency table.
Rows identify grade; columns identify travel mode.
Cell
An entry at the intersection of a row and column.
means participating Grade 9 students travel mainly by bus.
Margins
The row and column totals, which summarize one variable at a time.
is the Grade 9 total; is the bus total across both grades.
Grand total
The number of observations in the table, .
; also .
Read a cell by combining its two labels. Read a margin by identifying which label has been kept and which has been combined. The row totals and column totals each add to ; adding both sets together would count every student times.
Swapping rows and columns gives another valid orientation of the same data. It does not change which students are counted together. Keep the category labels clear, because the denominator for a comparison follows the question, not a rule that rows are always correct.
Think first: do the separate grade totals, and , and travel totals, , and , tell you exactly how many Grade 9 students walk?
Check your prediction
No. Those margins do not specify the combinations. Different cell arrangements can have the same row and column totals. The two-way table preserves the paired information needed to see that Grade 9 students walk.
Grade level is categorical here: 9 and 10 name the groups being compared. A table that records two quantitative measurements, such as height and mass, calls for other displays. A table of grade counts alone contains only one categorical variable.
Counts and proportions answer different questions
A frequency is a count. A relative frequency is a count divided by a specified total, written as a proportion or percentage. A two-way table can display either, so check its caption and labels before interpreting an entry.
Grade 10 has ; Grade 9 has . Counts answer this question directly.
Grade 10: . Grade 9: . Use the relevant grade total for each comparison.
For Grade 9 walkers: .
A group distribution lists all of its category shares. Grade 9’s travel distribution is bus, walk and car ride. Grade 10’s is bus, walk and car ride. Each list adds to because the modes are mutually exclusive and cover every student in its grade.
Dividing every cell by instead produces shares of the entire data set. For example, says that of all participating students are Grade 9 walkers. It does not say that of Grade 9 students walk.
Ask “out of whom?” An unlabeled percentage is incomplete. A table of percentages of all students and a table of percentages within each grade describe different reference groups.
This lesson uses simple within-group percentages to read graphs and compare patterns. Topic 2.2 develops the joint, marginal and conditional relative-frequency calculations in more detail.
Side-by-side and segmented bar charts
Side-by-side bar chart: compare a category across groups
A side-by-side bar chart, also called a grouped bar chart, places the groups’ bars next to each other within each category. Bars can run vertically or horizontally. Their heights or lengths show counts or relative frequencies, as stated on the scale.
The bars show counts, not within-grade proportions. come from the frequency table above.
The count chart shows that both grades have walkers. It also shows car riders in Grade 10 compared with in Grade 9. The grades have unequal totals, so compare within-grade percentages when the question is about travel patterns rather than the numbers using each mode.
Each grade uses its own total as the denominator. Compare the same travel category across grades.
The percentage chart uses each grade as its own reference group. For bus travel, compare in Grade 9 with in Grade 10. For walking, compare with . For car travel, compare with . A matching category and a common scale make the contrasts readable.
On this side-by-side percentage chart, the collectively add to . The do not need to add to : they refer to different grades.
Segmented bar chart: compare each group’s whole distribution
A segmented bar chart divides a bar into category pieces. Here we use a segmented bar chart: each grade has an equal-length bar representing its full distribution, and the segment lengths show its category percentages.
Both full bars represent of their own grade. Their equal lengths do not imply equal numbers of students.
Grade 9 has a larger bus segment; Grade 10 has a larger car-ride segment. Equal full bar lengths help compare proportions without the larger grade dominating the display. The labels and still tell you how many students those bars represent.
Read a segment’s length, not its ending position. In the Grade 9 bar, walking runs from to , so its share is . It is not .
A stacked bar chart can instead use counts, making each full bar’s length the group’s total. Check the units before assuming that every segmented display is standardized to . Keep the same category order and legend when comparing groups.
Read a mosaic plot
A mosaic plot divides a rectangle into group columns and category pieces. In the version below, we first split by grade. Column width represents that grade’s share of all students. Within a column, segment height represents the travel-mode share within that grade.
Vertical scale: percentage within each grade. Width: share of all students. Bus is at the base, Walk in the middle, Car ride at the top.
The complete rectangle represents all students. Segment labels give within-grade percentages; areas give whole-table shares.
- Widths: Grade 9 is of the total; Grade 10 is . The widths are in the ratio .
- Heights within a column: the bus segment occupies of the Grade 9 column and of the Grade 10 column.
- Area: each cell’s area represents its share of the complete data set. Grade 9 bus area is of the plot, corresponding to of the students.
The Grade 10 car-ride cell covers of the plot, corresponding to students. A broad column tells you that the group is large, not that every category has a high proportion within it.
Equal areas need not mean equal within-group percentages. Both grades have walkers, so the walker cells each occupy of the plot. Their heights differ: in the narrower Grade 9 column and in the wider Grade 10 column.
Compare the heights of the same category across columns to assess travel patterns. With a consistent category order, differently placed internal boundaries reveal different distributions. You can reverse the initial split and build a travel-mode-first mosaic; that changes which groups the column widths describe, so read the labels again.
This mosaic has proportional widths and no decorative gaps between columns. In a mosaic with equal-width grade columns, the group-size information would be lost. An ordinary segmented chart can use equal-sized bars because it has a different purpose.
Recognize an association between categories
Two categorical variables are associated in a data set when the distribution of one variable differs across categories of the other. In the school data, knowing a student’s grade changes the observed travel distribution: the car-ride share is in Grade 9 and in Grade 10.
Compare matching category proportions. Do not decide from the fact that one group is bigger, that the table has unequal counts, or that one category is common overall. A bus total of tells us how common bus travel is overall, but not how its share varies by grade.
Car ride is in Grade 9 and in Grade 10. The within-grade patterns differ.
Group A: yes, no. Group B: yes, no. Both are yes and no.
These are bars. The second example is a different fictional data set, not another view of the school table.
The counterexample has different group sizes but matching distributions of yes and no. Its count bars would differ, yet its bars have the same internal boundary. In those constructed data there is no observed association between group membership and the yes/no response.
If at least one matching category share differs, the full distributions differ. Conversely, finding that one share matches does not establish that every share matches when there are . Check the entire pattern.
Keep claims at the right level: a graph can show an association in the observed students. Establishing a population association requires appropriate collection and statistical analysis. Establishing a causal effect needs a suitable experimental design; the travel table provides no random assignment.
For nominal categories, avoid describing the relationship with a correlation coefficient or a “positive slope.” Say which group has a higher proportion in which category. An association is a distribution comparison, not a claim that all members of a group behave alike.
Five worked examples
These are original fictional teaching examples. The graph values come from the displayed tables; they are not results from a real school survey.
Example 1: Complete and interpret a two-way table
Task: the Grade 10 total is . Its bus count is and walk count is . Find its car-ride count, then interpret the school-wide walker total.
- Use the row’s total: the cover all students in that grade, with .
- Find the missing count: car riders.
- Combine the grades for walkers: walkers.
- Interpret the margin: participating students, across both grades, travel mainly by walking. It is not the count in each grade.
Check: Grade 10’s row sums to , and the column totals sum to . A table’s margins are totals, not additional observations.
Example 2: Repair a count-based comparison
Task: a student says, “Both grades have walkers, so walking is equally common in both grades.” Assess the statement.
- Clarify “common”: the walker numbers match. The proportions need not match because the grade totals differ.
- Compare Grade 9’s share: .
- Compare Grade 10’s share: .
- Write a supported comparison: the same number walk in each grade, but the walking proportion is higher in Grade 9 by percentage points.
A side-by-side percentage chart or segmented chart reveals this contrast. “ percentage points” is the subtraction ; it is different from a relative increase.
Example 3: Read a bar’s boundaries
Task: the Grade 9 segmented bar has a bus/walk boundary at and a walk/car boundary at . Find the walking and car-ride shares and their counts.
- Locate the walker segment: it extends from to .
- Subtract endpoints: walking.
- Read the remaining final segment: car ride.
- Use the stated grade size: walkers; car riders.
Without the grade total, the percentage bar alone would not tell you the counts. Segment labels and the group-size note supply different information.
Example 4: Interpret a mosaic cell
Task: compare the in the school mosaic. Why do they have equal areas even though their heights differ?
- Grade 9 width: . Its walker height is .
- Grade 9 walker area share: .
- Grade 10 width: . Its walker height is .
- Grade 10 walker area share: .
- Connect area to counts: each rectangle represents of , or students. The narrower column needs a taller segment for the same area.
Takeaway: use height for the within-grade walker proportion, width for the grade share, and area for the combination’s share of all students.
Example 5: Unequal counts without an observed association
Task: Group A has respondents: yes and no. Group B has respondents: yes and no. A student claims an association because Group B has .
- Check group sizes: B also has overall.
- Compare response distributions: A is yes and no; B is yes and no.
- Identify the graphical pattern: both bars have the same split at . In a group-first mosaic, B’s column is wider, but corresponding segment heights match.
- Assess the claim: the count difference does not show an association here. The response distribution is the same in these .
This constructed example does not prove that two variables are independent in every possible population. It illustrates why matching within-group distributions, rather than matching raw counts, are the relevant comparison.
Explain a comparison in context
A good explanation names the variables, identifies the groups being compared, and gives evidence from a matching category on a suitable scale. Finish with the claim that the evidence supports.
Compare the mode distribution within Grade 9 with that within Grade 10.
The shares are for Grade 9 and for Grade 10.
The mode distribution differs by grade. The table does not establish a causal effect.
Writing frame: “Among [observed units], [category] accounts for [percentage] of [group A] and [percentage] of [group B]. Because the distributions differ across [grouping variable], the data show an association between [variable 1] and [variable 2].”
Applied to the example: “Among the participating students, of Grade 9 students and of Grade 10 students travel mainly by car ride. Travel mode therefore has a different distribution in the two grades, showing an association between grade level and main travel mode in these data.”
For a claim about numbers, use numbers: “There are Grade 10 car riders and Grade 9 car riders.” For a claim about a group’s share, use its denominator: “ are car riders.” Neither sentence says that are in Grade 10.
Say what the graph cannot tell you
The table does not explain why the travel distributions differ. Distance from school, family arrangements or other features could be related to both grade and travel mode. Grade was not randomly assigned, and the data do not justify a cause-and-effect claim.
The example describes participating students. Before generalizing to all students, inspect how participants were selected and how accurately travel mode was recorded. Before claiming convincing evidence of a population association, use appropriate inference rather than a visual impression alone.
A descriptive difference can be real in the displayed data without establishing a statistically significant population relationship. This topic focuses on reading representations and explaining their evidence.
Common mistakes and how to fix them
| Mistake | Why it fails | Better approach |
|---|---|---|
| Comparing raw counts to decide which group has the higher proportion. | A larger group can have more observations in a category even with a smaller category share. | Divide by each relevant group total, or read a properly labeled percentage display. |
| “ is the Grade 9 walking percentage.” | includes both grades. | Use for the share within Grade 9; describes Grade 9 walkers among everyone. |
| Adding row totals and column totals to find the sample size. | Each set already counts every observation once. | Add one set of margins, or use the grand total. |
| Reading a segment’s upper endpoint as its percentage. | An interior segment begins . | Subtract its starting endpoint from its ending endpoint. |
| Assuming equal bar sizes mean equal group sizes. | Standardizing removes group-size differences from the full bar lengths. | Read the labels or the frequency table. |
| Making unequal-sized groups equally wide in a proportional mosaic. | The widths no longer represent their shares of the total. | Use proportional widths; here and . |
| Using mosaic area as the percentage within a group. | Area combines group share and within-group category share. | Use segment height within that column for the category proportion. |
| “One category matches, so there is no association.” | Other category shares may differ. | Check the full distributions, especially with . |
| “Different bars prove causation.” | The display describes a relationship without supplying a causal design. | State an association in context and inspect the study design before making a causal claim. |
| Comparing different legends, category orders or scales as if they match. | A color or position may represent something different in each group. | Match the category labels and use a consistent scale, order and legend. |
When checking a graph, look for a clear title, group labels, a count or percentage scale, and an unambiguous legend. Count bar lengths need a to represent counts proportionally. A bar must cover exactly the complete group, allowing small rounding discrepancies in printed labels.
Eight practice questions with hints and solutions
All situations are fictional. Write your comparison before opening the solution. When using a percentage, state the reference group.
1. Identify the two variables
A school records each participating student’s grade level, Grade 9 or Grade 10, and main travel mode, bus, walk or car ride. Name the observational unit and the two variables. Does using 9 and 10 as labels make grade level a quantitative measurement here?
Hint
What does one row of the original student data describe? Do the numbers measure an amount, or identify groups?
Solution and explanation
The unit is . The variables are grade level and main travel mode, both categorical in this comparison. The grade labels identify ordered categories rather than a quantitative amount measured on each student. Their numerical appearance does not change the table’s purpose.
2. Complete the table and choose a denominator
A café records preferred drink for respondents. Of morning respondents, prefer coffee and the rest prefer tea. Of afternoon respondents, prefer tea and the rest prefer coffee. Find the missing counts and the overall drink totals. What percentage of morning respondents prefer tea?
Hint
Use each session total before combining sessions. For the final percentage, who is the reference group?
Solution and explanation
Morning tea: . Afternoon coffee: . Overall tea: ; overall coffee: . Among morning respondents, tea accounts for . Dividing by would instead give the share of all respondents who are morning tea-preferrers.
3. A taller count bar can have a smaller proportion
A count chart shows yes responses in Group A and in Group B. Group A contains respondents; Group B contains . A student says A has the larger yes proportion because exceeds . Assess the claim and give a suitable graph choice.
Hint
Compare yes responses out of each group’s own total.
Solution and explanation
A’s yes proportion is ; B’s is . A has more yes responses but the smaller yes proportion. A side-by-side within-group percentage chart or segmented chart makes the proportional comparison clearer. The count chart is appropriate for the different question of which group has more yes responses.
4. Read an interior segment
A bar displays bus, then walk, then car ride. Its first boundary is and its second boundary is . State all . Is the walking share ?
Hint
The walking segment starts at , .
Solution and explanation
Bus: . Walk: . Car ride: . The walking share is not ; that endpoint combines bus and walk. The shares sum to .
5. Separate mosaic width, height and area
A mosaic represents responses. Group A occupies of its width and Group B . The yes segment occupies of A’s height and of B’s height. Find the yes proportion within each group, the yes count in each, and each yes rectangle’s share of the whole plot.
Hint
Width gives a group’s share of . Height gives the yes share of that group. Multiply them for area.
Solution and explanation
A contains respondents and B contains . A is yes, giving yes responses; B is yes, giving . The yes areas are of the plot for A and for B. A has the higher yes proportion but the smaller yes count and area.
6. Evaluate a cause-and-effect claim
Using the school travel table, a student says, “Moving to Grade 10 causes students to travel by car because the car-ride percentage rises from to .” Give a supported interpretation and explain the overstatement.
Hint
Was grade randomly assigned? What does the table actually show?
Solution and explanation
The observed car-ride share is in Grade 9 and in Grade 10, so grade level and travel mode are associated in these data. Grade was not randomly assigned, and other differences could contribute to travel choices. The table does not establish that changing grade causes a change in travel mode, or that a particular student would change mode.
7. Check a claimed chart
A bar labeled “Percentage within Group A” has labeled yes and no. Every respondent is in , and the chart gives no indication that the percentages are rounded. What is wrong? What should you check before repairing it?
Hint
Can a complete group occupy of itself?
Solution and explanation
The labels total , which is incompatible with a complete . Check the original counts, the Group A total and whether both percentages use that same reference group. Then recompute and redraw the pieces. Do not silently change to without verifying the underlying values; either entry or its labeling could be wrong.
8. One matching category is not the whole distribution
In Group A, choose red, blue and green. In Group B, choose red, blue and green. A student says there is no association because the red proportions match. Assess the claim using both distributions.
Hint
Check blue and green as well as red.
Solution and explanation
The full distributions differ. Blue is in A versus in B, and green is versus . These differences show an association between group and color choice in the displayed data, even though the red shares match. A segmented chart would have the same red boundary but a different blue/green boundary.
Quick revision checklist
Quick questions students often ask
Can a two-way table have more than two rows or columns?
Yes. “Two-way” refers to two variables, not two categories. A grade-by-mode table can have grade rows and mode columns, plus totals. Each variable can have several categories.
Must the row percentages or the column percentages be used?
Use the reference groups specified by the question. To compare travel within grades when grades are rows, divide by row totals. If the same table is transposed so grades are columns, divide by column totals. Orientation changes the calculation’s position, not its meaning.
Can two groups have different counts but the same distribution?
Yes. Group A’s yes and no, and Group B’s yes and no, both produce yes and no. The count difference reflects different group sizes, while the category proportions match.
Is a mosaic plot the same as a segmented chart?
They can show the same within-group pattern. The mosaic also encodes group size through proportional widths. A segmented chart usually gives equal-sized full bars, so obtain the group counts from labels or the table rather than bar size.
Final understanding check
A fictional learning center records the course schedule and main study location of survey respondents. Each learner selects . The data are:
| Schedule | Library | Home | Other | Total |
|---|---|---|---|---|
| Day | ||||
| Evening | ||||
| Total |
- Name the observational unit and both categorical variables.
- Write the study-location distribution within each schedule.
- Choose a graph for comparing those distributions and specify what its scale represents.
- Give the Day and Evening widths in a schedule-first mosaic. Find the whole-plot area share for the Day-library cell.
- Explain whether the observed variables are associated, using matching category evidence.
- Assess “Evening classes cause learners to study at home.”
Reveal the full solution
1. Variables: is the unit. The variables are course schedule, Day or Evening, and main study location, Library, Home or Other.
2. Distributions: Day: library, home, and other. Evening: library, home, and other. Each schedule’s percentages add to .
3. Graph: a segmented bar chart, with , uses segment lengths to show within-schedule location percentages. Keep category order and colors consistent, and label the group sizes and . A side-by-side within-schedule percentage chart is also appropriate.
4. Mosaic: Day width is ; Evening width is . The Day-library cell has height within Day, so its area share is of the plot. This equals . It is different from the library share within Day.
5. Association: among respondents, the home share is for Day and for Evening. Library shares also differ, versus . Thus study-location distributions differ by schedule, showing an association in these data. The matching Other share does not undo the differences elsewhere.
6. Scope: the survey does not randomly assign class schedules. Other differences between learners could be related to their study choices. Describe an association among the respondents; the table alone does not establish a causal effect or justify a claim about all learners.
Ready to move on? You should be able to read a table entry in context, choose a graph that answers the question, identify what each graphical dimension represents, and support an association claim with an appropriate comparison.
Continue learning
Topic 2.2: Summary Statistics for Two Categorical Variables →
Calculate and interpret joint, marginal and conditional relative frequencies, and use those summaries to compare categorical distributions.
Previous: Topic 1.13 — Experimental Design · Review bar charts · Review the mosaic · Back to the lesson overview