Displaying Categorical Data: What to Know 3

Bar Graphs

One of the most commonly used graphs for visualizing the distribution of a categorical variable is a bar graph. In a bar graph, categories are represented by bars that are separated from each other. The bars can be vertical or horizontal, and the height (or length) of each bar represents the measure of the data in each category. Bars can represent frequencies, relative frequencies (proportion), or percentages.

The bar graph is titled "Vertical Bar Graph" with the x-axis labeled "Eye Color", and the y-axis labeled "Height (in inches)". The height (in inches) ranges from 0-80 in increments of 10. The eye color and their heights (in inches) are as follows: Blue 48, Brown 72, Grey 59, Hazel 76, and Green 63.The bar graph is titled "Horizontal Bar Graph" with the x-axis labeled "Height (in inches)", and the y-axis labeled "Eye Color". The height (in inches) ranges from 0-80 in increments of 10. The eye color and their heights (in inches) are as follows: Blue 48, Brown 72, Grey 59, Hazel 76, and Green 63.

Interpreting bar graphs

At this point, students will be presented with two datasets. They will be able to choose which one they would like to use to answer example questions before creating bar graphs using the data analysis tool.

The bar graph below displays the number of cones each of a small ice cream shop sold on the 4th of July. Note that the counts (numbers of cones) are listed on the vertical axis while each flavor sold is listed along the horizontal axis. Examine the graph, then answer the questions in the Example that follows.

A bar graph entitled "Ice Cream Sales." Butter Pecan has a count of less than 10. Strawberry has a count of more than 50 and less than 60. Neapolitan has a count of 30. Vanilla has a count of 45. Chocolate has a count of 50. Cookies and Cream has a count of 30. Mint Chocolate chip has a count of 60. Other has a count between 20 and 30.

Example

Use the Ice Cream Flavors bar graph above to answer these questions.

a)  Which flavor sold the fewest number of cones?

 

b) About how many cones of Neapolitan ice cream were sold? 

Now that you have had a chance to become familiar with this categorical visualization, follow the directions below to use technology to create a bar graph for a real dataset.

Creating bar graphs from data

Recall the frequency table you created earlier in this section using the Describing and Exploring Categorical Data tool. When you used the technology tool to create the frequency table, a bar graph was also created on that page. Let’s go back to the tool to explore the bar graph. If you still have the tool open for this dataset, just follow steps 4 and 5 below to view the bar graph.

Go to the data analysis tool  Describing and Exploring Categorical Data  at   https://dcmathpathways.shinyapps.io/EDA_categorical/

Step 1) Select the One Categorical Variable tab.

Step 2) Locate the dropdown under Enter Data and select From Textbook.

Step 3) Locate the dropdown under Dataset and select Young Adults: Enjoy Music.

See the bar graph under the frequency table on the tool page. You can change the appearance of the graph using the Options selections. You can show counts or percentages on the vertical axis or in the bars, change the bars from vertical to horizontal, customize order, and even change the color of the bars in the Modify/Include section. Let’s explore how to change the bars from vertical to horizontal and then change the horizontal axis from Count to Percent (%).

Step 4) Click the Horizontal Bars box to change the perspective of the graph from counts as bar-heights to bar-lengths. Note how the Count range switches from the vertical axis to the horizontal axis. 

Step 5) Click the Show Percent box to change the heights (or lengths of horizontal bars) from counts to percentages. Note how the Count range switches to Percent (%). 

Take a moment to explore switching these options back and forth to see how the graph changes then answer Question 5 below.

question 5

Pie Charts

Another common graph used for displaying the distribution of categorical data is a pie chart. In a pie chart, categories are represented by wedges in a circle and are proportional in size to the percentage of individuals/items in each category. There are several ways to present pie chart data visually. A pie chart may include all the information needed to read it within each wedge or they may provided some image in the chart and some in a key off to the side.

The pie chart is titled "Students in a Course" and includes 4 sections: Freshman (35%), Sophomore (29%), Junior (23%), and Senior (13%). These percentages are included inside the pie chart.The pie chart is titled "Students in a Course" and includes 4 sections: Freshman (35%), Sophomore (29%), Junior (23%), and Senior (13%). In this pie chart, only the percentages are included inside the pie chart with the student classifications listed outside of the pie chart in a legend.

Interpreting pie charts

Pie charts are useful for showing percentages (parts of a whole) at some particular instance in time. For example, the following chart displays flavors of ice cream sold at an ice cream shop as a percentage of all ice cream sales on July 4th. This chart contains the same information as the bar chart does above, but shows percentages rather than counts.

The pie chart is titled "Ice Cream Sales" and is divided into 8 sections: Butter Pecan (2%), Strawberry (18%), Neapolitan (10%), Vanilla (15%), Chocolate (17%), Cookies and Cream (10%), Mint Chocolate Chip (20%), Other (8%).

Example

Use the chart above to answer the following questions.

a) What flavor made up the largest percentage of ice cream sales?

b) What percent of sales was attributed to strawberry ice cream?

Creating pie charts from data

When you used the Describing and Exploring Categorical Data data tool to create the frequency table and bar graph, you also had the option to create a pie chart. Let’s do that now. If you still have the tool open, skip to Step 4 below.

Go to the data analysis tool  Describing and Exploring Categorical Data  at   https://dcmathpathways.shinyapps.io/EDA_categorical/

Step 1) Select the One Categorical Variable tab.

Step 2) Locate the dropdown under Enter Data and select From Textbook.

Step 3) Locate the dropdown under Dataset and select Young Adults: Enjoy Music.

Step 4) Under the Additional Plots section, select Pie ChartScroll down to see the pie chart on the page under the bar graph.

question 6

It’s difficult to visualize a summary of the Enjoy music categories since just one or two of them dominate the chart. Let’s leave the tool now and explore another one of the variables from the dataset: Punctuality. The following pie chart displays the distribution of the categorical variable Punctuality. Use this pie chart to answer Questions 7 and 8 below.

A pie chart of young adults punctuality. The section for "I am often early" is 38.5%. The section for "I am always on time" is 34.6%. The section for "I am often running late" is 26.9%.

question 7

question 8