AP STATISTICS • EXPLORING ONE-VARIABLE DATA

Representing a Categorical Variable with Graphs

Transform categorical data into clear visual displays that reveal patterns, comparisons, and distributions at a glance.

Historical Context & Motivation

Long before the formal discipline of statistics emerged, humans recognized that summarizing information visually could reveal patterns invisible in raw tables of numbers. The challenge of representing categorical data—data that classify observations into groups or labels rather than measuring them on a numerical scale—drove many of the earliest innovations in data visualization. From William Playfair's pioneering charts in the late eighteenth century to Florence Nightingale's compelling polar-area diagrams during the Crimean War, statisticians and reformers understood that the right graph could communicate distributions, expose inequities, and guide policy in ways that columns of figures simply could not.

1786
Playfair's Bar Chart
Scottish engineer William Playfair publishes the first known bar chart in The Commercial and Political Atlas, comparing Scotland's trade with different nations using rectangular bars.
1801
Playfair's Pie Chart
Playfair introduces the pie chart in The Statistical Breviary, showing proportions of the Turkish Empire's territorial divisions as slices of a circle.
1858
Nightingale's Coxcomb Diagram
Florence Nightingale uses polar-area ("coxcomb") diagrams to categorize causes of soldier mortality—disease, wounds, and other—persuading the British government to improve sanitary conditions.
1977
Tukey's EDA Revolution
John Tukey's Exploratory Data Analysis formalizes the philosophy that data should be visualized before any inferential procedures are applied, elevating graphical summaries to a central role in statistics.
2000s
Modern AP Statistics Curriculum
The College Board enshrines graphical representation of categorical variables as the first skill in the AP Statistics curriculum, reflecting the consensus that data exploration begins with effective visualization.

The central question motivating this topic remains the same one Playfair faced more than two centuries ago: given a set of observations that fall into distinct categories, how can we construct a visual display that faithfully and efficiently communicates the distribution of those categories—their frequencies, relative frequencies, and the comparisons among them? Choosing the right graph is not merely an aesthetic decision; it determines whether the viewer can quickly and accurately interpret the data.

Core Principles & Definitions

Before constructing any graph, you must first recognize the nature of the variable you are displaying. A categorical variable places each individual into one of several groups or categories; common examples include political party affiliation, blood type, or the letter grade earned in a course. Unlike quantitative variables, categorical variables have no inherent numerical ordering (nominal data) or, at most, a natural order without meaningful arithmetic differences (ordinal data). Understanding this distinction is essential because the graphical tools appropriate for categorical data differ fundamentally from histograms and boxplots, which are designed for quantitative data.

1

Frequency

The count of observations falling into a particular category. The sum of all frequencies equals the total sample size, n.
2

Relative Frequency

The proportion of observations in a category: frequency divided by n. Relative frequencies always sum to 1 (or 100% when expressed as percentages).
3

Bar Chart

A graph with rectangular bars whose lengths correspond to the frequency or relative frequency of each category. Bars are separated by gaps to emphasize that the categories are discrete.
4

Pie Chart

A circular chart divided into sectors, where each sector's central angle is proportional to the relative frequency. Best used with few categories and when displaying parts of a whole.
5

Segmented (Stacked) Bar Chart

A single bar (or set of bars) divided into colored segments representing each category. Often used for comparing distributions across two or more groups.
KEY TAKEAWAY
Think of a categorical variable like a set of labeled bins on a sorting line: each observation gets placed into exactly one bin, and the graph's job is to show how full each bin is relative to the others. A bar chart lines the bins up side by side so you can compare heights, while a pie chart arranges them as slices of a single disk so you can see each bin's share of the total. The key insight is that gaps between bars signal categorical data, whereas touching bars (as in a histogram) signal quantitative data.

Visual Explanation — Bar Chart Anatomy

The bar chart is the workhorse of categorical data display on the AP Statistics exam. The following diagram illustrates the essential components using a hypothetical survey of 200 students asked about their preferred mode of transportation to campus. Note the clearly labeled axes, the gaps between bars, and the inclusion of a descriptive title—all elements that AP free-response graders look for.

A bar chart of transportation preferences. Notice the gaps between bars (signaling discrete categories), frequency counts above each bar, clearly labeled axes, and a descriptive title that includes the sample size.

Several design features in this bar chart deserve attention. First, the horizontal axis displays the category names, while the vertical axis displays frequency (count); you could equivalently display relative frequency or percentage on the vertical axis, and this choice should match whatever the question asks. Second, the bars do not touch—the gaps visually communicate that the categories are not continuous. This is a critical distinction from histograms, where adjacent bars touch because the variable is quantitative. Third, the order of the bars for a nominal variable is arbitrary; you may arrange them by decreasing frequency (producing a Pareto chart) or in any other logical order. For ordinal variables, however, the natural order should be preserved.

Mathematical Framework

Although graphs of categorical data are primarily visual tools, a precise mathematical foundation ensures that every bar height, sector angle, and segment width is computed correctly. The calculations center on frequency, relative frequency, and—for pie charts—conversion of relative frequencies to angles.

RELATIVE FREQUENCY
Relative Frequency of category i = fᵢ / n
where fᵢ is the frequency (count) of category i and n is the total number of observations. The sum of all relative frequencies must equal 1.
PERCENTAGE
Percentage of category i = (fᵢ / n) × 100%
Percentages are simply relative frequencies expressed on a 0–100 scale. All percentages must sum to 100% (subject to rounding).
PIE CHART CENTRAL ANGLE
θᵢ = (fᵢ / n) × 360°
Each category's sector spans an angle proportional to its relative frequency. The sum of all central angles equals 360°. For example, a category representing 25% of the data occupies 0.25 × 360° = 90°.
BAR HEIGHT (RELATIVE FREQUENCY SCALE)
Bar height for category i = fᵢ / n
When the vertical axis is scaled in relative frequency rather than raw count, each bar's height equals the proportion. This is especially useful when comparing groups of different sizes.
📝 AP Exam Tip
On free-response questions, always label both axes, give the graph a descriptive title (including context and sample size when possible), and scale the vertical axis so it starts at zero. Failing to start at zero can distort visual comparisons and is a common error that graders penalize.

Detailed Breakdown of Graph Types

The AP Statistics curriculum emphasizes three primary graphical displays for categorical variables: bar charts, pie charts, and segmented bar charts. Each has particular strengths depending on the question being asked and the number of categories involved. The diagram below provides a side-by-side comparison of a pie chart and a segmented bar chart using the same transportation data from Section 3, allowing you to see how the same distribution appears across different display formats.

The pie chart (left) emphasizes each category's share of the whole, while the segmented bar chart (right) stacks all categories into a single bar scaled from 0% to 100%. Both displays convey the same information; the segmented bar chart is generally easier to read when comparing across multiple groups side by side.
Summary of common graph types for categorical data
Graph TypeBest ForKey Feature
Bar ChartComparing frequencies or relative frequencies across categoriesBars are separated by gaps; can be vertical or horizontal
Pie ChartShowing parts of a whole when there are few (≤ 6) categoriesSector angles proportional to relative frequency; entire circle = 100%
Segmented Bar ChartComparing categorical distributions across two or more groupsColored segments stacked in a single bar; total height represents 100% (or n)
Side-by-Side Bar ChartDirectly comparing frequencies of the same categories across groupsGrouped bars placed adjacent for each category; a legend identifies each group
⚠️ When NOT to Use a Pie Chart
Pie charts become difficult to interpret when there are many categories or when several categories have similar sizes—human perception of angles is inherently less precise than perception of bar lengths. If your data have more than six categories, a bar chart is almost always the better choice. The AP exam commonly tests whether students can identify an appropriate display for a given context.

Worked Example

A university dining services survey asks 500 students to name their favorite type of cuisine. The results are: Italian (140), Mexican (120), Chinese (95), Indian (75), and Thai (70). Construct a relative frequency bar chart and determine the central angle each category would occupy in a pie chart.

Cuisine Preference Survey — Bar Chart & Pie Chart Construction
1
Step 1 — Organize the Data into a Frequency TableList each category and its frequency: Italian = 140, Mexican = 120, Chinese = 95, Indian = 75, Thai = 70. Confirm that the total is 140 + 120 + 95 + 75 + 70 = 500, which matches the stated sample size n = 500.
Total confirmed: n = 500
2
Step 2 — Compute Relative FrequenciesDivide each frequency by 500. Italian: 140/500 = 0.28; Mexican: 120/500 = 0.24; Chinese: 95/500 = 0.19; Indian: 75/500 = 0.15; Thai: 70/500 = 0.14. Verify that 0.28 + 0.24 + 0.19 + 0.15 + 0.14 = 1.00.
Sum of relative frequencies = 1.00 ✓
3
Step 3 — Draw the Bar ChartOn the horizontal axis, place the five cuisine categories. On the vertical axis, scale from 0 to at least 0.30 (relative frequency). Draw a bar for each category at the computed height—Italian at 0.28, Mexican at 0.24, Chinese at 0.19, Indian at 0.15, and Thai at 0.14. Leave gaps between bars. Label both axes, and title the graph: "Relative Frequency of Favorite Cuisine (n = 500)."
Bar chart drawn with labeled axes, title, and gaps
4
Step 4 — Compute Central Angles for Pie ChartMultiply each relative frequency by 360°. Italian: 0.28 × 360° = 100.8°; Mexican: 0.24 × 360° = 86.4°; Chinese: 0.19 × 360° = 68.4°; Indian: 0.15 × 360° = 54.0°; Thai: 0.14 × 360° = 50.4°. Verify: 100.8 + 86.4 + 68.4 + 54.0 + 50.4 = 360.0°.
Sum of central angles = 360° ✓
5
Step 5 — Interpret the DisplaysBoth the bar chart and the pie chart show that Italian cuisine is the most preferred category, followed by Mexican. No single cuisine dominates (no category exceeds 30%), so students' preferences are somewhat spread out. In the bar chart this is visible as a gradual decline in bar heights; in the pie chart it appears as five sectors of roughly similar—but not equal—size.
Italian is the modal category at 28%; preferences are relatively evenly distributed

Strengths & Limitations of Each Display

No single graph type is universally best for every situation. The choice between a bar chart, pie chart, and segmented bar chart depends on the number of categories, the question being addressed, and whether comparisons across groups are required. The table below distills the key trade-offs.

Comparison of graphical displays for categorical variables
CriterionBar ChartPie ChartSegmented Bar Chart
Ease of comparing categoriesExcellent — bar lengths are easy to compare visuallyModerate — angle comparison is less precise than lengthGood for broad comparisons; harder for small differences
Part-of-whole clarityLimited — viewer must mentally compute proportionsExcellent — the circle inherently represents the wholeExcellent — full bar height = 100%
Many categories (> 6)Handles well; use horizontal layout if labels are longPoor — too many thin slices become unreadableAcceptable but colors may become hard to distinguish
Comparing groupsUse side-by-side bar chart with grouped barsPoor — comparing two circles is cognitively demandingIdeal — place bars for different groups side by side
AP exam preferenceMost commonly expected display; always safeAcceptable but rarely the optimal choiceFrequently tested in two-way table / conditional distribution contexts
KEY TAKEAWAY
When in doubt on the AP exam, default to a bar chart. It works well for any number of categories, allows precise comparison of frequencies, and avoids the perceptual pitfalls of pie charts. Think of the bar chart as the Swiss Army knife of categorical displays—versatile, reliable, and always acceptable. Reserve segmented bar charts for the specific situation where you need to compare conditional distributions across two or more groups.

Connection to Two-Way Tables & Advanced Analysis

Representing a single categorical variable with a graph is the entry point into a larger ecosystem of statistical analysis. When a second categorical variable is introduced, the data can be organized in a two-way table (also called a contingency table), and the graphical displays extend naturally. Side-by-side bar charts and segmented bar charts become tools for visualizing conditional distributions—the distribution of one variable given a fixed level of the other. These visual comparisons then motivate the formal inferential procedure tested later in the AP course: the chi-square test for independence.

From one-variable displays to two-variable inference
This LessonWhere It Leads
Bar chart of one categorical variableSide-by-side bar charts comparing conditional distributions across groups
Relative frequency and percentage calculationsJoint, marginal, and conditional relative frequencies in two-way tables
Segmented bar chart for one variableMosaic plots and segmented bars comparing conditional distributions
Visual comparison of category proportionsChi-square test for homogeneity / independence (Unit 8 of AP Statistics)

Mastering the construction and interpretation of single-variable categorical graphs now sets a strong foundation for these more advanced topics. Every skill practiced here—computing relative frequencies, choosing the right display, and writing clear interpretations in context—transfers directly to the analysis of associations between two categorical variables. When you eventually encounter a two-way table on the AP exam, you will essentially be constructing multiple one-variable bar charts and comparing them, so the fluency you build now pays dividends throughout the course.

Practice Problems

1
A student creates a graph to display the distribution of favorite colors among 150 classmates. The graph has rectangular bars that touch each other with no gaps. Which of the following best describes the problem with this display?
2
In a survey of 400 adults, 160 prefer streaming service A, 100 prefer streaming service B, 80 prefer service C, and 60 prefer service D. What is the central angle for service B in a pie chart?
3
A researcher surveys 600 registered voters in two counties about their party affiliation (Democrat, Republican, Independent). In County X (n = 350), the relative frequencies are 0.40, 0.35, and 0.25. In County Y (n = 250), the relative frequencies are 0.30, 0.50, and 0.20. Which graphical display would most effectively allow a reader to compare the conditional distributions of party affiliation between the two counties, and why?
PROBLEM 4APPLIED
A hospital emergency department collects data on the primary reason for each visit over the past year. The categories and their frequencies are shown below. Injury: 2,400 Chest pain: 1,800 Abdominal pain: 1,500 Respiratory distress: 1,200 Fever: 900 Other: 2,200 Total: 10,020 (a) Construct a well-labeled relative frequency bar chart for these data. Include all necessary components. (b) Determine whether a pie chart would be an appropriate alternative display. Justify your answer. (c) The hospital administrator notices that "Other" has the second-highest frequency. Discuss what this suggests about the category scheme and how it might affect the usefulness of any graphical display.
PROBLEM 5CRITICAL THINKING
A news organization publishes the following graphic to argue that political Party Z has gained enormous support: a bar chart showing Party Z's vote share in the last election as 18% and in the current election as 22%, but the vertical axis starts at 16% rather than 0%. (a) Explain how the truncated vertical axis can mislead the viewer. (b) Redraw (or describe in detail) what the display would look like if the axis started at 0%, and explain how the visual impression changes. (c) Propose an alternative graphical strategy that honestly conveys the change while still making the 4-percentage-point increase visually apparent. (d) Generalize: state a principle about axis scaling in bar charts that applies to any categorical data display.

Summary

A categorical variable classifies individuals into groups or labels rather than measuring a numerical quantity. The three primary graphical displays for categorical data are the bar chart (rectangular bars with gaps, heights proportional to frequency or relative frequency), the pie chart (circle divided into sectors whose central angles equal (fᵢ / n) × 360°), and the segmented bar chart (stacked colored segments within a single bar, ideal for comparing distributions across groups).

When constructing any of these displays, remember to include a descriptive title, labeled axes, and a vertical axis starting at zero. The gaps between bars in a bar chart signal discrete categories and distinguish it from a histogram. Bar charts are the most versatile option and are preferred on the AP exam; pie charts should be reserved for situations with few categories where showing parts of a whole is the primary goal. These foundational skills connect directly to the analysis of two-way tables and conditional distributions later in the course.

Varsity Tutors • AP Statistics • Representing a Categorical Variable with Graphs