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:

1 Discrete scales

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

A bar graph with song valence on the x-axis and song title on the y-axis. Each bar is a different color, with colors following a rainbow-like palette.

We can then add some evermore-inspired colors using scale_fill_taylor_d().

p + scale_fill_taylor_d(album = "evermore")

The same bar graph as the previous figure, but the colors of the bars have been updated to use a palette inspired by the album cover of evermore. The palette starts with a dark brown, moving to orange, and finally to a light gray.

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")

The same bar graph as the previous two figures, but the colros of the bars have been updated to use a palette inspired by the album cover of Speak Now. The palette starts with a dark burnt red and then moves to purple and finally a light pink.

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()

A scatter plot with bill length on the x-axis and bill depth on the y-axis. The shape and color of the points correspond to the species of penguin, with colors derived from the color palette for Lover.

2 Continuous and binned scales

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)")