[R] expression exponent labeling
Berry Boessenkool
berryboessenkool at hotmail.com
Wed Mar 13 12:25:44 CET 2013
Hi all,
I want to label an axis with exponents, but can't get it done with expression.
Any hints would be very welcome!
# simulated data, somewhat similarly distributed to my real data:
set.seed(12); d <- rbeta(1e6, 0.2,2)*150 ; d <- d[d>1e-8]
hist( d , breaks=100)
# now on a logarithmically scaled axis:
hist(log10(d), breaks=100, xaxt="n")
abline(v= log10(1:10*10^rep(-9:3, each=10)), col="darkgrey" ); box()
hist(log10(d), breaks=100, col="forestgreen", add=T)
axis(1, log10(1:10*10^rep(-9:3, each=10)), labels=F)
axis(1, -2:2, format(10^(-2:2), scient=3, drop0trailing=T) )
# the labels with lower values should be in the form of 10^x:
axis(1, -8:-3, expression( 10^(-8:-3)) )# doesn't work, because expression returns only one output
for(i in -8:-3) axis(1, i, expression(10^i) ) # writes i at all locations
expression does exactly what it should, but I want something different here...
I've tried I(10^i) instead, but that's not right either.
Thanks ahead,
Berry
More information about the R-help
mailing list