Data Science Hour of Code
Activity 2: Labeling a ChartScenario:
- 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.
bill_depth | bill_length |
---|---|
18.7 | 39.1 |
18.3 | 37.8 |
18.5 | 36.8 |
13.2 | 46.1 |
17.9 | 46.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.
- Use the block(s) in the palette on the left.
- Place the 'chart:SetTitle("Penguins")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
- Place the 'chart:SetSubtitle("Bill Depth vs Bill Length")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
- Place the 'chart:SetXAxisTitle("Bill Depth")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
- Place the 'chart:SetYAxisTitle("Bill Length")' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
- Run the program.
- 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..