Data Science Hour of Code

Activity 2: Labeling a Chart

Scenario:

  • You're a data scientist working with a group of researchers from Antarctica.
  • They have collected a bunch of data about penguins, but need help answering questions about it.
  • Your job is to make some charts from the data and answer some of their questions.

Introduction:

Now we can investigate our data using a Scatter Plot instead of just looking at columns and rows in a spreadsheet. This can be helpful in exploring the relationship between two variables by plotting them on the X and Y axes. But before we move on, we should make sure we are using good labels on our chart. Looking at the samePenguins1.csv dataset, you might notice that the headers are sort of funny to read; 'bill_depth' and 'bill_length'. These headers are used for the labels of the X and Y axes when we make our chart by default, but we can make them (and the title/subtitle at the top) say whatever we want.

Sample of Penguins1.CSV file
bill_depthbill_length
18.739.1
18.337.8
18.536.8
13.246.1
17.946.5

Instructions:

In the code editor below, we have a program that creates a Chart with default labels. Take code blocks from the palette and place them below where we make the Chart object but before we Display it.

  1. Use the block(s) in the palette on the left.
  2. Place the 'chart:SetTitle("Penguins")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
  3. Place the 'chart:SetSubtitle("Bill Depth vs Bill Length")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
  4. Place the 'chart:SetXAxisTitle("Bill Depth")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
  5. Place the 'chart:SetYAxisTitle("Bill Length")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
  6. Run the program.
  7. Use the chart in the canvas to answer the questions in the Activity section.

Coding:

Blocks

Activity:

Use the chart(s) you've created in the Coding section to answer a few questions.








Next Tutorial

In the next tutorial, we will discuss Selecting the Data, which describes how to select different columns to display..