I have a normal distribution plot and a histogram plot with x axis in log scale displaying 0, 10^0, 10^1 ... I want to include minor ticks between the major ones. Actually I was
Here is a simple function to to this:
log10.axis <- function(side, at, ...) {
at.minor <- log10(outer(1:9, 10^(min(at):max(at))))
lab <- sapply(at, function(i) as.expression(bquote(10^ .(i))))
axis(side=side, at=at.minor, labels=NA, tcl=par("tcl")*0.5, ...)
axis(side=side, at=at, labels=lab, ...)
}
Here is an example:
x <- exp(rnorm(200, 5))
hist(log(x), 20, xaxt="n", xlim=c(0, 8))
log10.axis(1, at=seq(0, 8, 2))
Gives: