Skip to content

Instantly share code, notes, and snippets.

@will-r-chase
Created April 4, 2022 03:07
Show Gist options
  • Save will-r-chase/38f84952cd0f18370970883303ca3413 to your computer and use it in GitHub Desktop.
Save will-r-chase/38f84952cd0f18370970883303ca3413 to your computer and use it in GitHub Desktop.
library(tidyverse)
library(patchwork)
#Solutions
#Using charts in plastic_charts.R
#Create a patchwork with one chart in a lefthand column
#spanning two vertical rows, and two charts in a second column
#stacked on top of each other
patchwork <- bar_chart | (bar_chart_2 / pie_chart)
#Take the patchwork you just created, and add a title, subtitle, and figure labels
patchwork + plot_annotation(title = "Plastic pollution",
subtitle = "According to beach cleanups",
tag_levels = "A")
#Make the figure labels read "Fig. 1, Fig. 2, Fig. 3"
patchwork + plot_annotation(title = "Plastic pollution",
subtitle = "According to beach cleanups",
tag_levels = c(1),
tag_prefix = "Fig. ")
#Use theme options to make the figure labels a little smaller
patchwork + plot_annotation(title = "Plastic pollution",
subtitle = "According to beach cleanups",
tag_levels = c(1),
tag_prefix = "Fig. ") &
theme(plot.tag = element_text(size = 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment