[R] Setting xlim in lattice plots

Mike White mikewhite.diu at btconnect.com
Wed Mar 15 17:18:13 CET 2006


I am having difficulty setting different xlim values in the lattice
histogram plot function.
An example is shown below.  I think I need to convert the limits data.frame
to a list of paired values but don't know how. Any help would be
appreciated.

library(lattice)
mat <- as.data.frame(matrix(abs(c(rnorm(100),
10*rnorm(100),20*rnorm(100),30*rnorm(100))),ncol=4))
colnames(mat)<-c("C1","C2","C3","C4")
mat2<-stack(mat)

limits<-cbind(rep(0, ncol(mat)),apply(mat,2,max))
histogram(~ values | ind, data=mat2, xlim=limits,
scales=list(x=list(relation="free")))

Thanks
Mike White




More information about the R-help mailing list