Reputation: 41
I wish to have the same y-axis limits for a row of an xyplot
with a 2 by 2 display. Neither scales = "free"
, nor scales = "sliced"
will achieve this.
size <- rep(c("da","db","ca","cb"),each=5)
age <- rep(1:5,4)
growth <- rep(c(-75,-55,-25,-20),each=5)
test <- data.frame(size,age,growth)
xyplot(growth~age|factor(size),layout=c(2,2),
type=c("p","g"),
scales=list(x=list(tick.number=3)),
ylab="growth %",xlab="age",pch=20,col="black",
data=test)
in this case I would like to have (in base graphics): ylim=c(-50,-80)
for the first row and y=c(-20,-30)
for the second row.
Upvotes: 1
Views: 707
Reputation: 12654
You need to pass a list of limits to the xyplot
. Here I made a list outside of the xyplot
function but you could do that right in the scales
argument if you wish.
library(lattice)
size <- rep(c("da","db","ca","cb"),each=5)
age <- rep(1:5,4)
growth <- rep(c(-75,-55,-25,-20),each=5)
test <- data.frame(size,age,growth)
YLims<-list(c(-20,30),c(-20,30),c(-50,-80),c(-50,-80) )
xyplot(growth~age|factor(size),
layout=c(2,2),
type=c("p","g"),
scales=list(x=list(tick.number=3), y=list(relation="free", limits=YLims)),
ylab="growth %",xlab="age",pch=20,col="black", data=test)
Upvotes: 2