instagram

Students use data displays like bar and pie charts to create 1- and 2-level groupings to visualize the distribution of categorical data.

Lesson Goals

Students will be able to:

  • Read and create pie and bar charts

  • Explain the difference between pie and bar charts

  • Read and create stacked and multi bar charts

  • Explain the difference between pie and bar charts

Student-facing Lesson Goals

  • Let’s use functions to create pie and bar charts to visualize categorical data

  • Let’s visualize categorical data grouped in different ways

Materials

Supplemental Materials

Key Points for the Facilitator

This lesson uses the Expanded Animals Starter File, which includes far more animals than the smaller sample represented in the animals starter file used in most of our lessons.

🔗Grouping by Value 25 minutes

Overview

Students learn one way of grouping data, showing the frequency of values in a dataset using bar and pie charts.

Launch

  • How do the count table and bar chart you just made compare?

    • The height of each bar matches the count of each species.

  • How does this pie chart compare to the bar chart you just made?

    • The wedges show percentages, whereas the bar chart was labeled with the count. We could figure out how many animals were in the sample from the bar chart. With the pie chart we see how the categories compare to each other, but we have no way of knowing how many animals each wedge represents.

Investigate

Turn to Bar & Pie Chart - Notice and Wonder and take two minutes to notice and wonder about the displays. Then compare your Notices and Wonders with your partner.

2-column table titled value and count, cat 141, clownfish 2, dog 160, lizard 37, rabbit 41, snail 6, tarantula 20 A bar chart with count on the vertical axis (in increments of 20) and a bar for each species: cat 141, clownfish 2, dog 160, lizard 37, rabbit 41, snail 6, tarantula 20

Both bar-chart and count group the data in one column by value, creating "buckets" for each unique value and counting the number of rows in each bucket, one uses a picture and one uses a table.

When you first build a bar chart or pie chart in pyret, they are interactive displays. That means that you can mouse over a bar to reveal the label, as well as the number of animals in that species. We can also resize the window by dragging its borders. This allows us to experiment with the data before closing the window and generating the final, non-interactive image.

Bar charts group data by value to show frequency as a count.

A bar chart showing how many animals belong to each species with a popup box that says: tarantula 20 (4.9%) Pie charts show us the percentage of the data points that fall in each category. Hovering over a pie slice reveals the label, as well as the count and the percentage of the whole. In this example we see that there is 1 animal that is a snail, representing 3.1% of the population.

Pie charts group data by value to show frequency as a percentage.

If our data is based on sample data from a larger population, we can use these charts to infer the proportion of a whole population that might belong to each category. For example, the distribution of species in our shelter might help us make guesses about the distribution of species in other shelters.

While bars in some bar charts should follow some logical order (alphabetical, small-medium-large, etc), the pie slices and bars can really be placed in any order, without changing the meaning of the chart.

  • What information is provided in bar charts that is hidden in pie charts?

    • Categories containing 0% of the data aren’t represented on a pie chart.

  • Why might it sometimes be problematic to use a pie chart, thereby hiding a category?

    • If, for example, a sector of the population is unrepresented in positions of power, it’s easier to ignore the issue if that population doesn’t get represented in the display.

  • Why isn’t it useful to group the pounds column using bar-chart or pie-chart?

    • Grouping by value works well for categorical data, when lots of different data points can be sorted into a smaller number of buckets. But for quantitative data - which can have lots of different values - the number of buckets is too large to be useful.

Grouping by value works well when lots of different data points can be sorted into a smaller number of buckets.

Common Misconceptions

  • Bar charts look a lot like another kind of chart - called a "histogram" - which are actually quite different because they display quantitative data, not categorical. This lesson focuses entirely on pie- and bar charts.

  • When comparing bar charts, it is important to read the scales on the y-axes. If the scales do not match, a taller bar may not represent a larger value.

  • The percentages on pie charts will always add to 100%, so if there are 5 subgroups of a population and we’re only going to look at data from 2 of the subgroups, it wouldn’t make sense to use a pie chart to compare them!

  • Relatedly, pie charts only have a wedge for each category whose population is large enough to claim a percentage of the pie. Unlike in bar charts, empty categories will not be included in a pie chart.

Synthesize

  • How is pie-chart similar to bar-chart? How is it different?

  • When would you want to use one chart instead of another?

  • Which displays do you find it easier to interpret? Why?

  • What questions about the dataset are you curious to investigate using these displays?

Optional Extension

Sometimes we want to visualize data that is already summarized:

Hair Color Number of Students

"Black"

5

"Brown"

13

"Blond"

4

"Red"

2

"Pink"

1

In this situation, we want to use the values in the first column for the labels of our pie slices or bars, and the values in the second column for the size. We have contracts for those, too: # pie-chart-summarized :: (Tabletable-name, Stringlabels, Stringvalues) -> Image # bar-chart-summarized :: (Tabletable-name, Stringlabels, Stringvalues) -> Image

Open the Hair Color Starter File to try them out!

🔗Groups and Subgroups 20 minutes

Overview

Students learn how to create groups within groups, showing the relative frequency of one variable across values of another variable using stacked and multi bar charts.

Launch

Turn to Introducing Displays for Subgroups and complete Part A now.

Comparing groups is great, but sometimes we want to compare sub-groups across groups. In this example, we want to compare the distribution of sexes across each species.

  • Let’s step away from the Animals Dataset for a moment to learn about some new kinds of displays that would make it easier to answer questions like these by revealing the subgroups in a column. Turn to Multi Bar & Stacked Bar Charts - Notice and Wonder.

  • What do you Notice? What do you Wonder?

Investigate

Pyret has two functions that let us specify both a group and a subgroup:

# stacked-bar-chart :: (Tabletable-name, Stringgroup, Stringsubgroup) -> Image

# multi-bar-chart :: (Tabletable-name, Stringgroup, Stringsubgroup) -> Image

Stacked Bar Chart

Multi Bar Chart

A stacked bar chart, showing the distribution of sexes across clownfish (100% hermaphrodite), snails (100% hermaphrodite), rabbits (39% female, 61% male), tarantulas (55% female, 45% male), lizards (54% female, 46% male), dogs (46% female, 54% male), cats (56% female, 44% male)

A multi bar chart, showing the distribution of sexes across clownfish (2 hermaphrodite), snails (6 hermaphrodite), dogs (73 female, 87 male), cats (79 female, 62 male), rabbits (16 female, 25 male), lizards (20 female, 17 male),  and tarantulas (11 female, 9 male)

Stacked Bar Charts put the groups side by side, so it’s easy to answer which species is the "most female". But it’s more difficult to see whether there are more female dogs than male cats, because the bars don’t all start from the bottom and they’re in percentages rather than raw quantities.

Multi Bar Charts put the subgroups side by side, so it’s easy to answer whether there are more female dogs than male cats in the shelter. But it’s a little more difficult to see which species is the "most female", because we have to estimate the relative lengths of each bar.

Synthesize

All of the charts we’ve looked at in this lesson work with categorical data, showing us the frequency of values in one or two groups.

  • What are some of the questions you asked about the animals dataset using these displays? And what did you learn?

  • What kinds of questions need stacked or multi bar charts, rather than pie or bar charts

  • What kinds of questions are better answered by stacked bar charts?

  • What kinds of questions are better answered by multi bar charts?

Optional Project: Making Infographics

Infographics are a powerful tool for communicating information, especially when made by people who actually understand how to connect visuals to data in meaningful ways. Project: Make an Infographic is an opportunity for students to become more flexible math thinkers while tapping into their creativity. This project can be made on the computer or with pencil and paper.

🔗Additional Exercises

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.