Agenda


Modify X and Y axis

  • title
  • labels
  • limits
  • breaks
  • position

Intro


In this module, we will learn how to modify the X and Y axis using the following functions:

  • Continuous Axis
    • scale_x_continuous()
    • scale_y_continuous()
  • Discrete Axis
    • scale_x_discrete()
    • scale_y_discrete()

Library


library(ggplot2)
library(dplyr)
library(tidyr)

Continuous Axis


scale_x_continuous() and scale_y_continuous() take the following arguments:

  • name
  • limits
  • breaks
  • labels
  • position

X Axis - Continuous


ggplot(mtcars) +
  geom_point(aes(disp, mpg))

Axis Label


ggplot(mtcars) +
  geom_point(aes(disp, mpg)) +
  scale_x_continuous(name = "Displacement")