Data Science Hour of Code
Activity 5: Customizing the ColorsScenario:
- 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:
You can select many different columns and factors at the same time. This breaks our data down into more and more groups, which each have their own color assigned so that we can differentiate them in the Chart. The first column we select is plotted against each of the other selected columns, and those sets are separated into groups based on the selected factors. So if we select Columns bill_depth and bill_length, and then we select Factors species and island, we end up getting 5 total groups of data (Note: not all of the species live on each island). Each of these comparisons is called a Series and is listed in our Legend. The points for each Series have a unique color, that way you can compare the trends. In this case, the default colors used are Dark Blue, Light Blue, Green, Teal and Purple. If you don't like these colors, there are many color palettes to choose from.
species | island | bill_depth | bill_length | flipper_length |
---|---|---|---|---|
Adelie | Torgersen | 18.7 | 39.1 | 181 |
Adelie | Biscoe | 18.3 | 37.8 | 174 |
Adelie | Dream | 18.5 | 36.8 | 193 |
Gentoo | Biscoe | 13.2 | 46.1 | 211 |
Chinstrap | Dream | 17.9 | 46.5 | 192 |
Instructions:
In the code editor below, we have a program that makes a Chart with two Series. 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:SetColorPaletteToCalm()' block below the 'ScatterPlot chart = frame:ScatterPlot()' block in the block editor.
- Run the program.
- To try other color options: stop the program, delete the block you added to the block editor and place one of the other blocks from the palette in the same location.
- 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 Separating into Sub-Charts, which describes how to separate the Chart into several Sub-Charts..