Manipulating axes (position scales) for continuous and discrete data in ggplot2 (CC154)
Channel: Riffomonas Project
Date: 2021-10-14

ggplot2 allows you to manipulate the appearance of axes - also called position scales - on your x and y axes for displaying continuous and discrete data. This episode of Code Club will show you how you can use various options in scale_x_continuous/scale_y_continuous and scale_x_discrete/scale_y_discrete to modify their appearance. With these functions, Pat also describes how they differ from coord_cartesian and xlim/ylim/limits and how to modify the padding at the ends of the axes using the expand argument and expansion helper function. The data depict the percentage of people in 15 countries who would be willing to receive the COVID-19 vaccine as of August and October of 2020.

In this episode, Pat uses #RStudio, #GitHub, and #git. The accompanying blog post can be found at https://www.riffomonas.org/code_club/2021-10-14-scales_xy.

Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at https://shop.riffomonas.org/youtube to get practice problems, tips, and insights.

R: https://r-project.org
RStudio: https://rstudio.com
Workshops: https://www.mothur.org/wiki/workshops

If you're interested in taking an upcoming 3 day R workshop be sure to check out our schedule at https://riffomonas.org/workshops/


You can also find complete tutorials for learning R with the tidyverse using...
Microbial ecology data: https://www.riffomonas.org/minimalR/
General data: https://www.riffomonas.org/generalR/

0:00 Types of data we can represent on axes
2:31 Using scale_x_discrete (or scale_y_discrete)
5:14 Using scale_y_continuous (or scale_y_continuous)
7:59 What about coord_cartesian and xlim/ylim/limits?
10:58 Changing the padding at the ends of the axes
14:14 Critique of axes