In addition to data sets, taylor also includes a few helper functions for easily making plots created with ggplot2 have a Taylor Swift theme. For this vignette, I’m assuming you are already familiar with ggplot2 and can make basic plots.
Once you have a ggplot created, you can add album-themed color palettes to your plots using the family of scale_taylor
functions:
scale_color_taylor_d()
scale_fill_taylor_d()
scale_color_taylor_c()
scale_fill_taylor_c()
scale_color_taylor_b()
scale_fill_taylor_b()
First, let’s make a bar graph showing the valence of each song on evermore.
library(taylor)
library(ggplot2)
evermore <- subset(taylor_album_songs, album_name == "evermore")
evermore$track_name <- factor(evermore$track_name, levels = evermore$track_name)
p <- ggplot(evermore, aes(x = valence, y = track_name, fill = track_name)) +
geom_col(show.legend = FALSE) +
expand_limits(x = c(0, 1)) +
labs(y = NULL) +
theme_minimal()
p
We can then add some evermore-inspired colors using scale_fill_taylor_d()
.
p + scale_fill_taylor_d(album = "evermore")
The album
argument can be changed to use a different Taylor-inspired palette. For example, we can switch to Speak Now using album = "Speak Now"
.
p + scale_fill_taylor_d(album = "Speak Now")
We can also use these functions for non-Taylor Swift data. For example, here we use scale_color_taylor_d()
to plot some data from the palmerpenguins package.
library(palmerpenguins)
ggplot(penguins, aes(x = bill_length_mm, y = bill_depth_mm)) +
geom_point(aes(shape = species, color = species), size = 3) +
scale_color_taylor_d(album = "Lover") +
theme_minimal()
When using a continuous scale, values are interpolated between the colors defined in each palette. The Fearless (Taylor’s Version) palette is a particularly good use case for this. To illustrate, we’ll use the classic example included in the ggplot2 package of the eruptions of the Old Faithful geyser and the duration of the eruptions.
p <- ggplot(faithfuld, aes(waiting, eruptions, fill = density)) +
geom_tile() +
theme_minimal()
p + scale_fill_taylor_c(album = "Fearless (Taylor's Version)")