Penguin plotting in chain
Combining plots for multiple groups allows you to compare qualities within and between those groups. Now let's combine it with the macro experience! In this exercise, you'll be looking at three different species of penguins, Adelie, Chinstrip, and Gentoo. Your colleagues think it might be possible to successfully infer the species by comparing the lengths of their flippers and their body mass. Let's see if they are right!
The penguins DataFrame has been imported for you, along with all the necessary packages.
Deze oefening maakt deel uit van de cursus
Data Manipulation in Julia
Oefeninstructies
- Inside the macro, group the
penguinsDataFrame by thespeciescolumn. - Create a scatter plot of the
flipper_length_mmagainst thebody_mass_gcolumns for the different groups, using the provided labels. You can usegdf[1]to access the first group of thegdfGroupedDataFrame. - Remember to plot all the species into a single plot.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
@chain penguins begin
# Group by species
____
# Create a scatter plot for each species group
____ ____(_[1].flipper_length_mm, _[1].body_mass_g, label="Adelie")
____ ____(____, ____, label="Chinstrip")
____(____, ____, label="Gentoo", legend=:topleft)
xlabel!("Flipper length in mm")
ylabel!("Body mass in g")
end