[R] Setting xlim in lattice plots

Mike White mikewhite.diu at btconnect.com
Thu Mar 16 09:36:04 CET 2006


Sundar
Thanks, that is what I needed, but is it possible to customise the xlim
ranges for individual plots and if so how do I convert the dataframe of
range values to the list format required by the histogram fuction?

Mike

----- Original Message ----- 
From: "Sundar Dorai-Raj" <sundar.dorai-raj at pdf.com>
To: "Mike White" <mikewhite.diu at btconnect.com>
Cc: <r-help at stat.math.ethz.ch>
Sent: Wednesday, March 15, 2006 5:08 PM
Subject: Re: [R] Setting xlim in lattice plots


>
>
> Mike White wrote:
> > 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
> >
>
>
> I think you want a breaks=NULL in your call to histogram:
>
> library(lattice)
> set.seed(42)
> mat <- data.frame(C1 = abs(rnorm(100)),
>                    C2 = abs(10 * rnorm(100)),
>                    C3 = abs(20 * rnorm(100)),
>                    C4 = abs(30 * rnorm(100)))
> mat2 <- stack(mat)
> histogram(~ values | ind, data = mat2, breaks = NULL,
>            scales = list(x = list(relation = "free")))
>
> HTH,
>
> --sundar
>




More information about the R-help mailing list