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.

A scatter plot with data columns and a percentage symbol.
Inside this lesson 10 sections 5 questions 9 figures

SECTION 1

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.

SECTION 2

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.

SECTION 3

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.

Preferred Transportation Mode (n = 200)0204060801008060302010CarBusBicycleWalkOtherTransportation ModeFrequency
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.

SECTION 4

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

RelativeFrequencyofcategoryi=fi/nRelative 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

Percentageofcategoryi=(fi/n)×100Percentage 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

θi=(fi/n)×360°θᵢ = (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)

Barheightforcategoryi=fi/nBar 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.

SECTION 5

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.

Pie Chart vs. Segmented Bar Chart — Same Data, Different ViewsPie ChartSegmented Bar Chart40%30%15%10%5%40%30%15%10%5%100%50%0%CarBusBicycleWalkOther
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.
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

Summary of common graph types for categorical data

⚠

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.

SECTION 6

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. 1

    Step 1 — Organize the Data into a Frequency Table

    List 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. 2

    Step 2 — Compute Relative Frequencies

    Divide 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. 3

    Step 3 — Draw the Bar Chart

    On 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. 4

    Step 4 — Compute Central Angles for Pie Chart

    Multiply 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. 5

    Step 5 — Interpret the Displays

    Both 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

SECTION 7

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.

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

Comparison of graphical displays for categorical variables

✦

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.

SECTION 8

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.

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)

From one-variable displays to two-variable inference

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.

SECTION 9

Practice Problems

Question 1: CONCEPTUAL

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?
  • A. The bars should be arranged in decreasing order of frequency.
  • B. The graph incorrectly implies a continuous quantitative variable because the bars have no gaps.
  • C. A pie chart must always be used instead of a bar chart for categorical data.
  • D. The sample size of 150 is too small for a bar chart to be appropriate.
  • E. Bars in a categorical display should overlap rather than touch.
Show answer (B)
The correct answer is B. When bars in a categorical bar chart touch one another, the display resembles a histogram, which is used for quantitative data. The gaps between bars in a bar chart visually communicate that the categories are discrete and non-continuous. Choice A is incorrect because, for a nominal variable like favorite color, bar order is flexible—decreasing order is common but not required. Choice C is incorrect because bar charts are perfectly appropriate (and often preferred) for categorical data. Choice D is incorrect because bar charts can be used with any sample size. Choice E is incorrect because bars in categorical displays should be separated by gaps, not overlapping.

Question 2: BASIC CALCULATION

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?
  • A. 25°
  • B. 72°
  • C. 90°
  • D. 100°
  • E. 144°
Show answer (C)
The correct answer is C. The central angle for service B is calculated as (100/400) × 360° = 0.25 × 360° = 90°. Choice A (25°) likely results from confusing the percentage (25%) with the angle. Choice B (72°) would correspond to a relative frequency of 0.20, perhaps from dividing 360° by the number of categories. Choice D (100°) incorrectly uses the frequency as the angle. Choice E (144°) corresponds to service A's angle: (160/400) × 360° = 144°, confusing the two services.

Question 3: INTERMEDIATE

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?
  • A. A pie chart for each county, because pie charts show parts of a whole
  • B. A frequency bar chart combining both counties, because it shows total counts
  • C. A segmented bar chart (using relative frequencies), because it places the distributions side by side on a common 0–100% scale
  • D. A histogram for each county, because it shows the shape of the distribution
  • E. A single bar chart of raw frequencies for all six category-county combinations
Show answer (C)
The correct answer is C. A segmented bar chart scaled to 100% places one stacked bar for County X and another for County Y side by side, each divided into segments for Democrat, Republican, and Independent. Because both bars reach 100%, the viewer can directly compare conditional relative frequencies despite the unequal sample sizes. Choice A is weaker because comparing two separate circles relies on angle perception, which is less precise than comparing aligned bar segments. Choice B is flawed because using raw frequencies would make County X's bars taller simply because it has more respondents, confounding sample size with distribution. Choice D is incorrect because histograms are used for quantitative data, not categorical. Choice E has the same confounding problem as B—unequal group sizes make frequency comparisons misleading.

Question 4: APPLIED

4 pts
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.
Show answer
Point 1 (Bar chart construction): The bar chart must have a descriptive title (e.g., "Relative Frequency of Primary Reason for ER Visit, n = 10,020"), a labeled horizontal axis with all six categories, and a vertical axis labeled "Relative Frequency" scaled from 0 to at least 0.25. Bars must be separated by gaps. Correct relative frequencies are: Injury ≈ 0.240, Chest pain ≈ 0.180, Abdominal pain ≈ 0.150, Respiratory distress ≈ 0.120, Fever ≈ 0.090, Other ≈ 0.220. Point 2 (Pie chart assessment): A pie chart is a defensible but potentially suboptimal choice. With six categories, it is on the boundary of readability. The student must note that because "Other" and "Injury" have similar relative frequencies (0.22 vs. 0.24), distinguishing these slices by angle would be difficult. A bar chart is preferable. Point 3 (Discussion of "Other" category): When a catch-all "Other" category has the second-largest frequency, it suggests that the classification scheme does not adequately capture the variety of reasons for ER visits. This makes the display less informative because a large "Other" hides important sub-categories that could influence policy decisions. Point 4 (Communication and context): The response must interpret the display in context—for example, noting that injury is the leading cause, accounting for about 24% of visits, and that the hospital might consider refining the "Other" category to yield more actionable data. All axis labels, titles, and interpretations must reference the real-world context of ER visits.

Question 5: CRITICAL THINKING

4 pts
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.
Show answer
Point 1 (Misleading truncation): When the vertical axis starts at 16% instead of 0%, the bar for 22% appears roughly three times as tall as the bar for 18% (since the visible portions are 6 units vs. 2 units). This exaggerates the visual magnitude of the change. In reality, 22% is only about 22% larger than 18% (a factor of 1.22), but the truncated axis makes it look like the support has tripled. Point 2 (Corrected display description): With the axis starting at 0% and ending at, say, 25% or 30%, the bar for 18% would be about 82% as tall as the bar for 22%. The increase would be visible but clearly modest—a small upward shift rather than a dramatic spike. The visual impression changes from "explosive growth" to "slight increase." Point 3 (Alternative strategy): One effective approach is to use a bar chart with a 0%-based axis but add a clear annotation or arrow between the two bars indicating "+4 percentage points." Another option is to include a side-by-side display: one panel showing the full bar chart (0% to 100%) for honest context, and a second panel showing a zoomed-in view (15%–25%) clearly labeled as a magnified inset. This balances honesty with emphasis on the change. Point 4 (General principle): Bar charts for categorical (or comparative) data should always have a vertical axis that starts at zero. Because the visual message of a bar chart relies on comparing bar lengths (or heights), a non-zero baseline distorts the ratios of those lengths and misleads the viewer. This principle applies to any display where the length of a graphical element encodes a quantity—bar charts, segmented bar charts, and similar displays.

SUMMARY

Summary

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