Tutorials › AP Statistics › Graphing Categorical Data With Technology

Graphs for categorical data · Tutorial 58 of 1000

Graphing Categorical Data With Technology

Practice turning frequency tables into clear bar charts and stacked charts, including 100% stacked charts that display within-group percentages.

Beginner 10 min read

What You'll Learn

  • Arrange category labels and frequencies so a spreadsheet or calculator plots the intended values.
  • Create a bar chart of counts or relative frequencies for one categorical variable.
  • Build a stacked chart from a two-way table and choose between counts and within-group percentages.
  • Recognize when a 100% stacked chart is the software equivalent of a segmented bar chart.
  • Check graph titles, axes, category order, totals, and scales for common technology errors.

From a Table to a Graph

A frequency table organizes categorical data into labels and counts. A spreadsheet or graphing calculator can turn those values into a graph quickly, but technology cannot decide which question the graph should answer. First choose the display that fits the question; then enter and check the data.

As discussed in Bar Chart Versus Segmented Bar Chart: Picking the Right One, a bar chart displays one categorical distribution, while a segmented bar chart compares conditional distributions across groups. In many spreadsheet programs, the matching option for a segmented bar chart is called a 100% stacked bar chart. A regular stacked chart instead stacks counts, so groups with different totals have different overall bar lengths. Knowing which chart option you selected is essential.

Key idea: Put category labels and their values in separate, clearly headed columns or rows. For a one-variable bar chart, plot the category counts or relative frequencies. For a segmented bar chart, arrange a two-way table so each group’s response counts—or conditional percentages—can be displayed as stacked segments.

Software menus vary, but the basic workflow is similar. Enter the table, select only the labels and values to graph, choose the graph type, and then edit the title, axes, and legend. Finally, compare the plotted values with the table. A correctly generated graph can still be misleading if the wrong cells were selected or if its labels are unclear.

Prepare the Table Before Selecting a Chart

For a one-variable bar chart, arrange the table with one category in each row and a count in the next column. Use a separate heading for each column, such as Activity and Count. Do not include the grand total as another category: it is not a response category and would create an extra bar.

For a stacked chart, arrange the two-way table with group categories in the first column and response categories in separate columns. Include the group totals only if you need them for calculations or checking. Unless the chart specifically needs to display those totals, do not select a totals column as though it were another response category.

Chart purposeUseful table arrangementWhat the chart displays
One categorical variableCategory and count (or relative frequency)One bar per category
Compare group countsGroup, then a column for each response categoryResponse counts stacked within each group
Compare group distributionsGroup, then a column for each response category’s within-group percentageEach group’s conditional distribution, totaling 100%

If the table gives counts but you want a 100% stacked chart, calculate the percentages first. As in Constructing a Segmented Bar Chart From a Two-Way Table, divide each cell count by its own group total and multiply by \(100\%\). The percentages for each group should add to \(100\%\), apart from small differences caused by rounding.

A General Technology Workflow

In a spreadsheet, place category names in one column and the values to plot in the next column or columns. Select the labels along with the data, insert the appropriate chart, and use the chart settings to confirm which series and labels the software is using. For a two-way table, the rows and columns may be interpreted in either direction; use the chart’s “switch rows and columns” or equivalent option if the groups and responses are reversed.

On a graphing calculator with a categorical chart or data-and-statistics feature, enter the categories and values in the format that feature requires, choose a bar or stacked display, and set the labels and scale. Some graphing calculators, including many common calculator models, do not make a labeled categorical bar chart directly from a frequency table using their standard statistical plots. Those plots may be designed for quantitative data or numerical lists instead. If your calculator lacks a categorical chart feature, use a spreadsheet or another approved tool rather than treating category codes as meaningful numerical measurements.

1
Match the chart to the question.
Choose a bar chart for one distribution. Choose a stacked display when comparing response categories across groups; select 100% stacked when comparing conditional distributions.
2
Enter and select the relevant data.
Include category labels and values. For a two-way table, include the group labels and response columns, but leave out grand totals unless they are intentionally part of the display.
3
Set the graph type and labels.
Choose bar, stacked, or 100% stacked as appropriate. Add a title, label the axes, identify the units or percentages, and make the legend clear.
4
Check the result against the table.
Confirm the category names, number of bars, plotted values, and scale. For a 100% stacked chart, check that each group totals 100%.

Worked Example: A Bar Chart of One Distribution

Worked Example: A Bar Chart of One Distribution

A fictional survey asks 48 visitors to a community garden which activity they would most like to try. The frequency table is: planting, 18; composting, 12; cooking, 10; and nature walks, 8. The question is which activity is most popular among these visitors.

Choose the graph. The question concerns the distribution of one categorical variable: preferred activity. A bar chart of counts is suitable. First check the table total: \(18+12+10+8=48\), which matches the number surveyed.

Enter the data. In a spreadsheet, enter the activity names in one column and the counts in the next. Select those two columns, including their headings, and insert a bar or column chart. If the software places the activity names in the legend and the counts along the horizontal axis, use its option to switch rows and columns so each activity is a category on the horizontal axis.

Label and verify. Use a title such as “Preferred Garden Activity Among 48 Surveyed Visitors.” Label the horizontal axis “Activity” and the vertical axis “Number of visitors.” The bar heights should be 18, 12, 10, and 8 in the table’s category order. The planting bar should be tallest and the nature-walks bar shortest.

A relative-frequency bar chart is also possible if the goal is to display shares rather than counts. The relative frequencies are:

$$ \frac{18}{48}=0.375=37.5\%,\quad \frac{12}{48}=0.250=25.0\%,\quad \frac{10}{48}\approx0.208=20.8\%,\quad \frac{8}{48}\approx0.167=16.7\%. $$

The rounded percentages total \(100.0\%\). For that version, graph the percentages rather than the counts and label the vertical axis “Percent of visitors.” Do not label an axis as percentages if the bars actually show counts.

Worked Example: A 100% Stacked Chart From Counts

Worked Example: A 100% Stacked Chart From Counts

A fictional school survey asks students in three clubs whether they favor holding a weekend event. The table records club and response. The question is whether the response distribution differs across clubs.

ClubFavorDo not favorTotal
Robotics18624
Garden151530
Art81220

Choose the graph and calculate within-group percentages. Since the question compares response distributions across clubs, use a 100% stacked chart. Calculate each response percentage using its own club total:

$$ \begin{aligned} \text{Robotics: }&18/24=75\%\text{ favor},\quad 6/24=25\%\text{ do not favor};\\ \text{Garden: }&15/30=50\%\text{ favor},\quad 15/30=50\%\text{ do not favor};\\ \text{Art: }&8/20=40\%\text{ favor},\quad 12/20=60\%\text{ do not favor}. \end{aligned} $$

The percentages within each club add to \(100\%\). In a spreadsheet, enter Club, Favor, and Do not favor columns, using these percentages as the response values. Select the labels and percentage columns, insert a 100% stacked chart, and make sure each club is a separate full bar. Label the vertical axis “Percent within club” and include a legend for the two responses.

The chart should show three bars of equal overall height, each representing \(100\%\). The favor segment should cover \(75\%\) of the Robotics bar, \(50\%\) of the Garden bar, and \(40\%\) of the Art bar. In this sample, the displayed conditional distributions differ: favoring the event is more common among surveyed Robotics Club students than among surveyed Art Club students.

A common technology mistake is to select the counts and choose a regular stacked chart, then assume every bar represents a full \(100\%\). That chart would stack counts, not percentages. To make the segmented comparison, either calculate the conditional percentages and choose a 100% stacked chart, or use the software’s 100% stacking option with counts and verify that it converts each group to proportions.

Worked Example: Counts or Percentages?

Worked Example: Counts or Percentages?

A fictional community program asks participants from morning, afternoon, and evening sessions whether they would attend a follow-up workshop. The counts are shown below. One question asks how many people in each session answered yes or no; another asks how the response distributions compare.

SessionYesNoTotal
Morning14620
Afternoon92130
Evening12820

For a count question, use a regular stacked chart. Enter the counts in the Yes and No columns and select a stacked chart. The total bar lengths will be 20 for Morning, 30 for Afternoon, and 20 for Evening, because the session totals are \(14+6=20\), \(9+21=30\), and \(12+8=20\). The Yes segments will have lengths 14, 9, and 12; the No segments will have lengths 6, 21, and 8. This makes the numbers of participants visible.

For a distribution comparison, use a 100% stacked chart. Calculate the conditional percentages:

$$ \begin{aligned} \text{Morning: }&14/20=70\%\text{ yes},\quad 6/20=30\%\text{ no};\\ \text{Afternoon: }&9/30=30\%\text{ yes},\quad 21/30=70\%\text{ no};\\ \text{Evening: }&12/20=60\%\text{ yes},\quad 8/20=40\%\text{ no}. \end{aligned} $$

Graphing these percentages in a 100% stacked chart makes all three bars equal in height. It emphasizes that the yes percentage is greatest in the Morning session and smallest in the Afternoon session. The regular stacked chart and the 100% stacked chart use the same table but answer different questions: one emphasizes counts, and the other emphasizes within-session percentages.

When using a calculator with a categorical graphing feature, the same distinction applies. Enter the response counts for a count-based stacked chart, or the computed within-group percentages for a segmented comparison. If the calculator requires numerical codes for categories, keep a separate key that maps each code to its category name; the codes are labels, not measured quantities.

Common Technology Errors and AP Exam Tips

  • Including totals as data categories. Selecting a grand-total cell can add an unintended bar or segment. Select only the category counts or response columns needed for the graph.
  • Using a stacked-count chart to compare distributions. A regular stacked chart displays counts, and group totals can differ. Use a 100% stacked chart or graph the calculated within-group percentages when the question compares conditional distributions.
  • Reversing groups and responses. Software may treat table rows as data series and columns as categories, or the other way around. Check that one bar represents each intended group and that the legend names the response categories.
  • Leaving unclear labels. A chart title such as “Survey” does not identify the group or variable. A clear title and labeled axes tell a reader what was recorded and whether values are counts or percentages.
  • Trusting default scales and formatting without checking. Confirm that the scale is appropriate, the category labels match the table, and bar heights correspond to the intended values. As discussed in Misleading Axes and Scales in Bar Charts, a scale that does not start at zero can exaggerate differences in bar lengths.
  • Interpreting category codes as numbers. If a calculator requires categories to be coded 1, 2, or 3, those numbers are identifiers. They do not mean that one category is quantitatively larger than another.

On an AP response, naming the software chart type is not enough. State what the bars or segments represent and why that display fits the question. For example: “Use a 100% stacked chart because the question compares the conditional distribution of response within each club; each club’s bar should total 100%.”

Key takeaway: Enter labels and values carefully, choose a chart that matches the question, and verify the result against the table. A regular stacked chart displays counts; a 100% stacked chart displays conditional percentages and corresponds to a segmented bar chart.

Check Your Understanding

Use the table layout and graph choices from this tutorial to answer each question.

  1. A frequency table lists four pet categories and their counts. What columns should you select for a bar chart, and why should you leave out the grand total?
  2. A two-way table records travel method by grade. The question asks how travel-method distributions compare across grades. Which stacked-chart option is appropriate, and what should each full bar represent?
  3. A spreadsheet shows group names in the legend and response categories on the horizontal axis, but you want one bar for each group. What chart setting could you change?
  4. A regular stacked chart displays Yes and No counts for two groups of different sizes. What does the total length of each bar represent, and why is that not the same as a 100% stacked chart?
  5. A calculator asks you to assign numbers to category labels. What should those codes mean, and what should they not be interpreted as?