ggtext examples and exercises
This lesson is called ggtext examples and exercises, part of the The Glamour of Graphics course. This lesson is called ggtext examples and exercises, part of the The Glamour of Graphics course.
Transcript
Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.
Loading transcript...
Your Turn
Adjust the code below, using ggtext to make the word ‘plastic’ bold in the title and wrapping the subtitle so it is multi-line.
library(tidyverse)
library(ggtext)
##Your turn
#Use ggtext to make the word 'plastic' bold in the title
#and wrap the subtitle so it is multi-line
plastics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-26/plastics.csv')
plastics %>%
group_by(year) %>%
summarize(total = sum(grand_total, na.rm = TRUE)) %>%
ggplot() +
geom_bar(aes(x = "", y = total, fill = as.character(year)), stat = "identity", width = 1) +
coord_polar("y", start = 0) +
theme_minimal() +
labs(title = "Plastic pollution, by year", fill = "",
subtitle = "This is a really really really long subtitle that has tons of detail about your methods and data and even more info beyond that") +
theme(axis.title = element_blank(), panel.grid = element_blank(),
axis.text = element_blank())
Course Content
37 Lessons