Make a reference figure

p1 <- penguins |> na.omit() |>
  ggplot(aes(body_mass_g, 
             flipper_length_mm,
             color = species,
             shape = island)) +
  geom_point()
p1

Built-in themes

Try some of:

p1 + theme_bw()

Try themes from the ggthemes package * theme_wsj, theme_tufte, theme_economist, theme_fivethirtyeight, theme_clean

library(ggthemes)
p1 + theme_wsj()

Text size

p1 + theme(text = element_text(size = 20))

p1 + theme(legend.text = element_text(color = "green"),
           legend.title = element_text(color = "blue"))

Read (some of the) help page for theme! At least enough to see what is there for future reference.

Change some of the “boxes” in the theme

p1 + theme(plot.background = element_rect(color = "orange",
                                          fill = "yellow"),
           legend.background = element_rect(color = "black",
                                            size = 0.2,
                                            linetype = "dotted"),
           panel.background = element_rect(color = "blue",
                                           fill = "#FF88FF"),
           panel.grid = element_blank(),
           axis.ticks.length = unit(1, "cm"))
## Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

Change the aspect ratio

p1 + theme(aspect.ratio = 0.4)