Re: [R] Fixing the physical size of Trellis graphs panels

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Thu, 10 Apr 2008 14:51:38 -0700

On 4/10/08, SĂ©bastien <pomchip_at_free.fr> wrote:
> Dear R-users,
>
> Please consider the following script:
>
> #####
>
> library(lattice)
> ID <- rep(1:8,each=2)
> x <- rep (c(1,2),8)
> y <- c(rep(c(0.5,2),4),rep(c(50,1000),4))
> df<-data.frame(ID,x,y)
> g <- rep(1:2,each=8)
> df.split<-split(df,g)
>
> df.split
>
> pdf(file="C:/Test.pdf")
>
> for (i in 1:2) {
> mydf<-as.data.frame(df.split[i])
> myplot<-xyplot(mydf[,3]~mydf[,2]|mydf[,1],
> data=mydf,
> layout=c(2,2))
> print(myplot)
> }
> dev.off()
>
> You will find that the physical size of the panels are different on page
> 1 and 2 because the axis labels have different length. Is it possible to
> fix the dimension of the panels regardless of the length of the axis labels?

Yes, look at the entry for panel.width and panel.height in ?print.trellis. You could use it as

print(myplot, panel.width = list(x = 3, unit = "inches"))

etc. See ?unit in the grid package for details.

-Deepayan



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 10 Apr 2008 - 21:54:13 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Apr 2008 - 22:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive