Representing a
Categorical Variable with Graphs
Learn to display categorical data using bar charts, pie charts, and more: choosing the right graph, reading distributions, and avoiding common pitfalls.
What Is a Categorical Variable?
A categorical variable places individuals into one of several groups or categories. Unlike quantitative variables (which measure amounts), categorical variables label or classify.
Why Graph Categorical Data?
A frequency table gives exact counts, but a graph lets you instantly compare category sizes, spot the mode, and communicate findings to an audience.
Frequency vs. Relative Frequency
Before graphing, you need to summarize the data. Two key summaries for categorical variables:
The Bar Chart
A bar chart displays each category as a separate bar. The height (or length) of each bar represents the frequency or relative frequency of that category.
Bar Chart Requirements
The Pie Chart
A pie chart displays each category as a slice of a circle. The angle (and area) of each slice is proportional to that category's relative frequency.
Bar Chart vs. Pie Chart
| Feature | Bar Chart | Pie Chart |
|---|---|---|
| Best for | Comparing sizes of categories | Showing parts of a whole |
| Number of categories | Any number | Few (3 to 6) |
| Can show frequency? | Yes | No: only relative frequency |
| Easy to compare? | Very easy | Harder for similar-sized slices |
| AP exam preference | Preferred | Acceptable but less common |
Segmented Bar Charts
When you have two categorical variables, a segmented (stacked) bar chart displays the conditional distribution of one variable within each category of the other.
Side-by-Side Bar Charts
An alternative for two categorical variables is the side-by-side bar chart: bars for each group are placed next to each other within each category, making direct comparison easier.
How to Choose the Right Graph
Example 1: Building a Bar Chart
A survey asked 200 students about their favorite subject. Results: Math: 60, English: 50, Science: 45, History: 30, Art: 15.
Example 2: Relative Frequency Chart
Using the same data (\(n = 200\)), convert to relative frequencies and create a relative frequency bar chart.
| Subject | Frequency | Relative Frequency |
|---|---|---|
| Math | 60 | 0.30 (30%) |
| English | 50 | 0.25 (25%) |
| Science | 45 | 0.225 (22.5%) |
| History | 30 | 0.15 (15%) |
| Art | 15 | 0.075 (7.5%) |
Example 3: Comparing Two Groups
A researcher records transportation mode for 9th graders (\(n = 120\)) and 12th graders (\(n = 100\)). Which graph best compares conditional distributions?
Describing a Categorical Distribution
When you describe a graph of categorical data on the AP exam, include these elements:
Common Mistakes to Avoid
Question 1 of 5
Which type of graph is most appropriate for displaying the distribution of a single categorical variable?
Question 2 of 5
In a bar chart, the bars should have gaps between them because:
Question 3 of 5
A survey of 400 adults finds that 160 prefer coffee, 120 prefer tea, 80 prefer juice, and 40 prefer water. What is the relative frequency for tea?
Question 4 of 5
When comparing the distribution of a categorical variable across two groups of different sizes, you should use:
Question 5 of 5
A pie chart is least appropriate when: