[R] figure layout

Cuvelier Etienne ecu at info.fundp.ac.be
Sun Apr 26 19:42:00 CEST 2009


hesicaia a écrit :
> Hello, 
> 
> I have a specific question regarding figure layout. I am tryng to make a 2
> by 1 figure but I would like to make the bottom figure slightly larger than
> the top figure. I have read through the help posts and have tried to use
> "fig=c(....),new=T" and have also tried to use "split.screen" and although
> they both work for most types of plotting(ie. hist, plot, etc...), for some
> strange reason, they do not function when I try to use them with the
> "metaplot" function in package "rmeta". The plot come out ok, but they are
> on two separate pages instead of the same one. I realize this is a very
> specific question, but was hoping someone might be able to suggest how I
> could achieve this. Below is my code for both "fig" and "split.screen",
> minus the axis labels which take up a lot of space in the code.
> Thanks very much, Daniel.

You can try to use the layout function:

?layout
#Example 1
# First plot take 3/5 of the screen
# Second plot 5/5of the screen
layout(matrix(c(0,1,1,1,0,2,2,2,2,2),nrow = 2, byrow=TRUE))
plot(density(rnorm(1000)))
plot(density(rnorm(1000)))

#Example 2
# First plot take 4/6 of the screen
# Second plot 6/6of the screen
layout(matrix(c(0,1,1,1,0,2,2,2,2,2),nrow = 2, byrow=TRUE))
plot(density(rnorm(1000)))
plot(density(rnorm(1000)))
...

I hope it helps.

Etienne

> 
> ***********************************************************************************
> library(rmeta)
> meta.n<-meta.summaries(ttable.n$lin.yeff,ttable.n$lin.se,method="random")
> conf.n<-1/(meta.n$se.summary^2)
> meta.c<-meta.summaries(ttable.c$lin.yeff,ttable.c$lin.se,method="random")
> conf.c<-1/(meta.c$se.summary^2)
> 
> bitmap("/scratch/dboyce/nmfs/figs/yeareffs.all.metaplot.dev.pdf",type="pdfwrite",res=800,height=6,width=6,pointsize=12)
> par(mfrow=c(2,1),mar=c(1,2,1,1),oma=c(4,6,.5,.5),cex.axis=.8,fig=c(0,1,.6,1))
> metaplot(mn=ttable.n$lin.yeff,se=ttable.n$lin.se,nn=(ttable.n$dev)-.05,labels=NULL,conf.level=0.95,summn=meta.n$summary,sumse=meta.n$se.summary,sumnn=conf.n/700,logeffect=F,colors=meta.colors(box="firebrick3",lines="gray38",zero="black",summary="blue",text="black"),xlim=c(-.06,.16),cex=1.2,ylab="",summlabel="",xaxt="n")
> axis(side=1,at=seq(-.06,.16,by=.03),labels=T)
> text(-.06,0.5,"A",cex=1.4)
> box()
>  
> par(fig=c(0,1,0,.6),new=T)
> metaplot(ttable.c$lin.yeff,ttable.c$lin.se,nn=ttable.c$dev,labels=NULL,conf.level=0.95,summn=meta.c$summary,sumse=meta.c$se.summary,sumnn=conf.c/7000,logeffect=F,colors=meta.colors(box="firebrick3",lines="gray38",zero="black",summary="blue",text="black"),xlim=c(-.02,.06),cex=1.2,summlabel="",ylab="",xaxt="n")
> text(-.02,0.5,"B",cex=1.4)
> axis(side=1,at=seq(-.02,.06,by=.01),labels=T)
> mtext("Instantaneous rate of change",side=1,line=3,cex=1.5)
> box()
> dev.off()
> 
> ************************************************************************************
> split.screen(figs=c(2,1),erase=F)
> screen(1)
> metaplot(mn=ttable.n$lin.yeff,se=ttable.n$lin.se,nn=(ttable.n$dev)-.05,labels=NULL,conf.level=0.95,summn=meta.n$summary,sumse=meta.n$se.summary,sumnn=conf.n/700,logeffect=F,colors=meta.colors(box="firebrick3",lines="gray38",zero="black",summary="blue",text="black"),xlim=c(-.06,.16),cex=1.2,ylab="",summlabel="",xaxt="n")
> screen(2)
> par(new=T)
> metaplot(ttable.c$lin.yeff,ttable.c$lin.se,nn=ttable.c$dev,labels=NULL,conf.level=0.95,summn=meta.c$summary,sumse=meta.c$se.summary,sumnn=conf.c/7000,logeffect=F,colors=meta.colors(box="firebrick3",lines="gray38",zero="black",summary="blue",text="black"),xlim=c(-.02,.06),cex=1.2,summlabel="",ylab="",xaxt="n")
> close.screen(all=T)
>




More information about the R-help mailing list