[R] Plots of different aspect ratios on one page, base aligned(trellis.print)

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Mar 25 17:11:30 CET 2009


On 3/10/09, Saptarshi Guha <saptarshi.guha at gmail.com> wrote:
> Hello,
>  I have an example of a 2 paneled plot, with two different aspect
>  ratios displayed on one page.
>  An example would help
>
>  n=20
>  x1 <- cumsum(runif(n))
>  x2 <- cumsum(runif(n))
>  d <- data.frame(val=c(x1,x2),id=c(1:n,1:n), nt=c(rep("A",n),rep("B",n)))
>  u1 <- xyplot(val~id | nt, data=d,aspect=1,layout=c(1,2))
>  u2 <- xyplot(val~id|nt, data=d,aspect=0.5,layout=c(1,2))
>  postscript("~/k.ps",colormodel="rgb",paper="letter",horiz=T)
>  print(u1,position=c(0,0,1/3,1),more=T,newpage=T)
>  print(u2,position=c(1/3,0,1,1),more=F,newpage=F)
>  dev.off()
>
>
>  The two figures are not base aligned. I would like them share the same
>  the baseline and same height, if necessary the paper width and height
>  can be adjusted
>  ( i tried setting the paper width and height to no avail).

This worked for me:

postscript("~/k.ps",colormodel="rgb",paper="special", horizontal = FALSE,
           height = 6, width = 10)

print(u1,position=c(0,0,1/3,1),more=T,newpage=T)
print(u2,position=c(1/3,0,1,1),more=F,newpage=F)

dev.off()


-Deepayan




More information about the R-help mailing list