Skip to content

Instantly share code, notes, and snippets.

@jglenes
Created November 24, 2013 01:44
Show Gist options
  • Save jglenes/7622349 to your computer and use it in GitHub Desktop.
Save jglenes/7622349 to your computer and use it in GitHub Desktop.
# Change the number of digits displayed on ggplot axes
# Define a number formatting function
fmt <- function(ndec) {
function(x) format(x,nsmall=ndec)
}
ggplot(mpg, aes(x=mpg$displ,y=mpg$hwy)) +
geom_point() +
scale_x_continuous(labels=fmt(2)) +
scale_y_continuous(labels=fmt(3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment