Saptarshi Guha
2009-Mar-10 17:23 UTC
[R] Plots of different aspect ratios on one page, base aligned(trellis.print)
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). Is the way to base align the two figures? Do I have to get down the grid level? Regards Saptarshi Guha
Deepayan Sarkar
2009-Mar-25 16:11 UTC
[R] Plots of different aspect ratios on one page, base aligned(trellis.print)
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
Apparently Analagous Threads
- Integration with variable bounds
- Replacement in an expression - can't use parse()
- Symbolic derivation using D in package stats - how do I properly convert the returned call into a character string?
- optimal control, maximization with several variables?
- Anomalous outputs from rbeta when using two different random number seeds