Grids, borders, lines, and axes examples and exercises
This lesson is called Grids, borders, lines, and axes examples and exercises, part of the The Glamour of Graphics course. This lesson is called Grids, borders, lines, and axes 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
Start with the code below. Then, apply the principles you have learned about for axes, grids, borders, etc to a plot you have made. The code below also has a starting plot for you if you prefer to use that.
##Your turn
library(tidyverse)
#plastic pollution dataset
plastics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-26/plastics.csv')
#Take a plot you made with the plastic pollution dataset (it doesn't need to be a scatter plot)
#And apply the principles you learned about for axes, grids, borders, etc.
#If you don't want to use your own plot, you can use this one...
#wrangle data
data <- plastics %>%
group_by(parent_company) %>%
summarize(total = sum(grand_total, na.rm = TRUE)) %>%
arrange(desc(total)) %>%
slice(4:14) %>%
mutate(parent_company = ifelse(parent_company == "NULL", "Unknown",
parent_company))
#example starting plot
ggplot(data) +
geom_col(aes(x = total, y = reorder(parent_company, total)), fill = "orchid4")
#now apply your styling of the grids, axes, borders, and backgrounds
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.
Blayne Beacham • February 21, 2023
Hey Will,
I really like the "g" and "mm" trick for the labelling of the x and y axes but I'm wondering if it is possible to just label the first (or last) instance of this and let the others be just the numbers. Is this possible?