Bar Charts

Bar charts are a common type of chart used within data science and often taught quite early within elementary school. Bar charts present categorical data with bars that represent the values. They may be vertical or horizontal.

Learning Objectives:

  1. Students will be able to create a bar chart from a dataset.
  2. Students will be able to label information displayed on the bar chart.
  3. Students will be able to customize bar charts.
  4. Students will be able to access the information from the bar charts using assistive technology.

Creating a Bar Chart using Quorum Studio (15 minutes)

To create a bar chart, we will begin by creating a DataFrame. In order to do this, we will need to first download the Nights Out dataset (as a CSV file). We will then need to add the Factors and Columns before running the program to display the bar chart. In this lesson we can follow the tutorial available on our website: Bar Charts.

To start us off we will download the dataset, so that we can have the means to create a bar chart.You can follow the link to download Nights Out dataset. If you are lost on how to download the dataset from GitHub, here is a link to our tutorial, Downloading CSVs for Our Charts.

Night Outs dataset describes how much does it cost to spend the night out in different countries and cities around the world. It has 5 columns and 92 rows, but we will not be using all of the columns in this example. We will be using 3 columns: 'Country,' 'Item,' and 'Cost.' Here is a snippet of what the dataset should look like:

Nights Out CSV
Category City Country Item Cost
Date NightBarcelonaSpainDinner69.38
Date NightBarcelonaSpainDrinks at Dinner21.28
Date NightBarcelonaSpainCinema Entry11.87
Party NightBarcelonaSpainTaxi10.92

To start creating a bar chart, we need to import two libraries. DataFrame, which is a frame where our chart will be drawn, and BarChart, which allows us to create a bar chart. Then we will initialize a DataFrame and load a comma separated values to the frame.

Reading and Displaying Data (5 minutes)

Now that we have the bar chart created, let us load the data from the comma separated file Nights Out and display the bar chart. The steps that we describe in this task can be followed in the 'Loading and Formatting' section that is available in our Bar Charts tutorial.

Currently, we have only loaded the comma separated value file into the dataframe, and we are not reading anything from it. The first thing that we need to do is to load the columns and factors to be read by our bar chart. Specifically, we will add the three columns that we will be using in this tutorial: 'Country,' 'Item,' and 'Cost.' After we have loaded factors and columns, we need to create a bar chart object using the frame that we have filled. Finally, we can display the content of that bar chart. Next, we will be labeling and customizing our bar chart.

Labeling the Bar Chart (15 minutes)

The next step is to be able to add specific labels to the bar chart, both axes, adding subtitles, and changing the font size of the print. Adding these features will allow us to present our data in a clearer way. The steps that we describe in this task can be followed in the 'Labeling the Bar Chart' section that is available in our Bar Charts tutorial.

First, we will add labels for our chart, x-axis, and y-axis. This allows the reader to distinguish between the information and to understand what data they are looking at. For our chart we can label it the following way: title - 'How Expensive are Night Outs Per Country?'; x-axis - 'Countries'; y-axis - 'Cost (in USD $).' If you feel like those labels are not enough, you can add a subtitle to the bar chart. For example, for this bar chart the subtitle cab be 'Various nightly activities cost in different countries.'

Customizing the Bar Chart (10 minutes)

Next, we explore how to change the color palette. The lesson uses the 'Colorgorical' palette but we want you to attempt to change the color palette by using the information on the Color Accessibility page.

The steps that we describe in this task can be followed in the 'Customizing the Bar Chart' section that is available in our Bar Charts tutorial.

Lastly, we can create a legend for the bar chart, which will allow us to describe the data even better for the reader. For this chart the legend can be 'Activity,' and we can also set the location to left, right, top or bottom. Note: by default the location is set to right.

Accessing the Bar Chart (10 minutes)

Now let us explore the graphic using the accessibility tools on our devices. When the bar chart has been created, we should see our chart pop up in a separate window. From there, we can reference this tutorial on keyboard navigation using the arrow keys for accessibility. One note is that when a bar chart is saved onto our computer devices, they save as an SVG (scalable vector graphic) which maintains not only resizability but accessibility to read these charts using a screen reader.

Relevant Common Core Standards

We use the following website for common core standards in relation to histograms and measurements of distribution.

CCSS.MATH.CONTENT.HSS.ID.A.1: Represent data with plots on the real number line (dot plots, histograms, and box plots).

Next Tutorial

In the next tutorial, we will discuss Descriptive Statistics, which describes Understanding statistics and how to calculate important values using Quorum..