[R] finer control of scales in xyplot
Benjamin Tyner
btyner at stat.purdue.edu
Mon Jan 8 20:41:09 CET 2007
When plotting over multiple pages in lattice, I'd like to be able to
have "same" scales within a page, but "free" scales between pages. In
other words, something like:
z<-data.frame(x=1:100,
y=runif(100),
d=rep(1:2,50),
p=rep(1:2,each=50))
plot<-xyplot(y~x|d*p,
data=z,
scales=list(x=list(relation="free")),
layout=c(1,2))
but within a page, to have common x-axes. As long as 'x' is sorted, I
can get the desired effect by transforming x to a relative scale:
plot<-xyplot(y~unlist(with(z,tapply(x,p,function(x)
(x-min(x))/diff(range(x)))))|d*p,
data=z,
layout=c(1,2))
except that I'd like the tickmark labels to be in the original units of
'x'. I've started looking at xscale.components.default to see whether it
can work on a per-page (instead of per-panel) basis, but I get the
nagging suspicion that I'm making this harder than it needs to be. Any
assistance greatly appreciated.
Thanks,
Ben
More information about the R-help
mailing list