Skip to content

Instantly share code, notes, and snippets.

@aravindhebbali
Last active September 26, 2017 07:18
Show Gist options
  • Save aravindhebbali/7c0968878e8cf989b669ae80ac32d15a to your computer and use it in GitHub Desktop.
Save aravindhebbali/7c0968878e8cf989b669ae80ac32d15a to your computer and use it in GitHub Desktop.
Data Visualization: Title & Axis Labels
# 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()
# create scatter plot
plot(mtcars$disp, mtcars$mpg)
# add title, subtitle and axis labels
title(main = 'Displacement vs Miles Per Gallon',
sub = 'Mileage is inversely related to Displacement',
xlab = 'Displacement', ylab = 'Miles Per Gallon')
# create scatter plot without axis labels
plot(mtcars$disp, mtcars$mpg, ann = FALSE)
# add title, subtitle and axis labels
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment