8.2 Plot and Axis Titles

base <- ggplot(penguins, aes(bill_length_mm, bill_depth_mm, 
                        color = species, shape = species)) +
  geom_point(alpha = .4) +
  geom_point(data = gd, size = 4) +
theme_bw() +
labs(
title = "How does Bill Size Differ by species?",
subtitle = "Source: Palmer Station Antarctica LTER and K. Gorman, 2020",
x = "*Length*",
y = "Width",
caption = "ggplot 2 Book Club") +
theme(plot.title = element_text(color = "midnightblue", 
      hjust = .5, face = "bold")) +
theme(plot.subtitle = element_text(hjust = .5, size = 9)) + 
theme(axis.title.x = ggtext::element_markdown()) 

  • line breaks
  • quote() for mathamatical expressions. ?plotmath
  • removing labels two ways: labs(x = ““) and labs(x = NULL)