log scaled y axis without scientific notation

85 views
Skip to first unread message

Sean O'Riordain

unread,
Jan 22, 2010, 4:46:42 AM1/22/10
to ggplot2
Good morning,

Is there a simpler way of doing a log10 plot but without scientific
notation like below?

and secondly, is there any possibility of doing the facet with scales='free_y' ?

Thanks,
Sean

############################
#
# create a fake dataset
#
require(ggplot2)

x1 <- seq(from=-4, to=2)
df1 <- data.frame(x=x1, y=10^x1)
df2 <- df1
df1$p <- 'red'
df2$p <- 'green'
df2$y <- df2$y / 100
df <- rbind(df1,df2)
df$q <- c('a','b')
rm(df1,df2,x1)

# now given the fake dataset above... do a "pretty" non-scientific
log10() y-scale
t0 <- floor(log10(range(df$y)))
t1 <- seq(from=t0[1], to=t0[2])
qplot(x, y, data=df, geom='line') +
facet_grid(p ~ q) +
scale_y_log10(breaks=10^t1, labels=format(10^t1, big.mark=',',
scientific=FALSE, trim=TRUE, drop0trailing=T))

hadley wickham

unread,
Jan 22, 2010, 10:00:45 AM1/22/10
to Sean O'Riordain, ggplot2
> Is there a simpler way of doing a log10 plot but without scientific
> notation like below?

Not currently.

> and secondly, is there any possibility of doing the facet with scales='free_y' ?

facet_grid(p ~ q, scales = "free_y") ?

Hadley

--
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages