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.
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())
Have any questions? Put them below and we will help you out!
Course Content
37 Lessons
You need to be signed-in to comment on this post. Login.
Deepak Varughese • January 29, 2023
Can i not use the same approach to create a multiline subtitle for a combination of plots using patchwork? It throws the following error
"Error: gridtext has encountered a tag that isn't supported yet: Only a very limited number of tags are currently supported. "