Number formatting axis labels in ggplot2?
ggplot2, r
Solution
One needs to load `library(scales)` before attempting this.
Problem
I'm plotting a fairly simple chart using ggplot2 0.9.1. ``` x <- rnorm(100, mean=100, sd = 1) * 1000000 y <- rnorm(100, mean=100, sd = 1) * 1000000 df <- data.frame(x,y) p.new <- ggplot(df,aes(x,y)) + geom_point() print(p.new) ``` Which works, but ggplot2 defaults to scientific notation that is inappropriate for my audience. If I want to change the x-axis label format by entering: ``` p.new + scale_x_continuous(labels = comma) ``` I get: Error in structure(list(call = match.call(), aesthetics = aesthetics, : object 'comma' not found What am I doing wrong? I note that the language changed recently from "formatter" to "labels". Perhaps I'm misreading the man page? Edit: I was indeed misreading the man page Need to load `library(scales)` before attempting this.