r - lattice separate y axes for row of xyplot -
i wish have same y-axis limits row of xyplot
2 2 display. neither scales = "free"
, nor scales = "sliced"
accomplish 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 case have (in base of operations graphics): ylim=c(-50,-80)
first row , y=c(-20,-30)
sec row.
you need pass list of limits xyplot
. here made list outside of xyplot
function right in scales
argument if 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)
r lattice
No comments:
Post a Comment