Facets
Exercise 1:
TODO
Exercise 2:
Below is the start of plotnine's documentation for facet_wrap
.

Notice that the Parameters section lists ncol
and nrow
options. These determine how many columns or rows to use. For example, the plot below has nrow = 1
.
Try out the plot as is, and with the nrow
argument changed to ncol = 1
.
Then, answer the questions below.
# This code keeps the 3 artists listed ----
artists_to_keep = ["Billie Eilish", "ITZY", "Roddy Ricch"]
some_artists = (
track_features
>> filter(_.artist.isin(artists_to_keep))
)
# This code plots the data ----
(some_artists
>> ggplot(aes("energy", "valence", color = "artist"))
+ geom_point()
+ facet_wrap("~artist", nrow = 1)
+ labs(title = "Song features across 3 artists")
)
Test yourself
Which of the three artists tends to have the lowest valence?
(click to answer)
Which value seems easier to compare across facets, when ncol is set to 1?