[R] Labels on axes with log scales with lattice
Jamieson Cobleigh
cobleigh at gmail.com
Sun Aug 14 21:47:04 CEST 2005
I using lattice to make some plots and I want to make the y-axis on
some of these plots use a log scale. In the following plot:
x <- 1:10
y <- 2^x
xyplot(log10(y) ~ x)
I get tick marks on the y-axis at 0.5, 1.0, 1.5, 2.0, 2.5, and 3.0. I
would rather have just 3 tick marks at 1.0, 2.0, and 3.0 but labeled
10, 100, and 1000.
I know this can be done using the "at" and "labels" parameters to the
"x" parameter to the "scales" parameter to the "xyplot" command.
xyplot(log10(y) ~ x, scales=list(y=list(at=c(1, 2, 3), labels=c(10,
100, 1000))))
My problem is that I am making multiple plots and cannot set the
labels on each plot individually. I need to automate the computation
of the "at" and "labels" parameters. I think the "axTicks" command
can compute the information I need to set "at" and "labels" correctly,
but I am having trouble determining how to set its parameters to make
it compute the information I need. Perhaps "pretty" might work to,
but "axTicks" seems better designed for handling logarithmic axes.
Does anyone have any suggestions?
Thanks in advance!
Jamie
More information about the R-help
mailing list