Agenda


  • Learn to add
    • title
    • subtitle
    • axis Labels
  • learn to modify
    • axis range

Syntax


Feature Argument Value Example
Title main string “Scatter Plot”
Subtitle sub string “Displacement vs Miles Per Gallon”
X Axis Label xlab string “Displacement”
Y Axis Label ylab string “Miles Per Gallon”

Title


plot(mtcars$disp, mtcars$mpg, 
     main = 'Displacement vs Miles Per Gallon')

Subtitle


plot(mtcars$disp, mtcars$mpg, 
     main = 'Displacement vs Miles Per Gallon',
     sub = 'Mileage is inversely related to Displacement')

Axis Labels


plot(mtcars$disp, mtcars$mpg, 
     main = 'Displacement vs Miles Per Gallon',
     sub = 'Mileage is inversely related to Displacement',
     xlab = 'Displacement', ylab = 'Miles Per Gallon')

title()


plot(mtcars$disp, mtcars$mpg) 

title(main = 'Displacement vs Miles Per Gallon',
      sub = 'Mileage is inversely related to Displacement',
      xlab = 'Displacement', ylab = 'Miles Per Gallon')

Annotate


plot(mtcars$disp, mtcars$mpg, ann = FALSE) 

title(main = 'Displacement vs Miles Per Gallon',
      sub = 'Mileage is inversely related to Displacement',
      xlab = 'Displacement', ylab = 'Miles Per Gallon')

Axis Range


plot(mtcars$disp, mtcars$mpg, 
     xlim = c(0, 600), ylim = c(0, 50))