Force R to stop plotting abbreviated axis labels - e.g. 1e+00 in ggplot2

JPD picture JPD · Jan 28, 2013 · Viewed 90.7k times · Source

In ggplot2 how can I stop axis labels being abbreviated - e.g. 1e+00, 1e+01 along the x axis once plotted? Ideally, I want to force R to display the actual values which in this case would be 1,10.

Any help much appreciated.

Answer

Arun picture Arun · Jan 28, 2013

I think you are looking for this:

require(ggplot2)
df <- data.frame(x=seq(1, 1e9, length.out=100), y=sample(100))
# displays x-axis in scientific notation
p  <- ggplot(data = df, aes(x=x, y=y)) + geom_line() + geom_point()
p

# displays as you require
require(scales)
p + scale_x_continuous(labels = comma)