[R] Labels on axes with log scales with lattice

From: Jamieson Cobleigh <cobleigh_at_gmail.com>
Date: Mon 15 Aug 2005 - 05:47:04 EST

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!


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Aug 15 05:54:40 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:49 EST