[R] Invoking par(mfrow...) on an already subdivided plot

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Oct 18 22:09:50 CEST 2009



Maxwell Reback wrote:
> I'd like to generate on a single device multiple plots, each of which
> contains two plots. Essentially, I've got sub-plots which consist of
> two tracks, the upper one displaying gene expression data, and the
> lower one mapping position. I'd like to display four of these
> two-track sub-plots on one device, but I can't seem to invoke the
> par(mfrow=...) or layout(matrix(...)) functions at more than one
> level.
> 
> I've got something like:
> 
> plot.gene<-function(gene){
> par(fig=c(0,1,0.3,1))                      #expression: track 1
> plot(...)
> par(fig=c(0,1,0,0.4),new=TRUE)     #position: track 2
> plot(...)}
> 
> plot.multigene<-function(gene,...){
> pdf(paste(gene,".pdf",sep=""))
> par(mfrow=c(2,2))
> tapply(gene,gene, plot.gene)
> dev.off()}
> 
> The par(mfrow=) in plot.multigene, even when 'new=TRUE', is
> disregarded and I just get one sub-plot per page. Suggestions?


You are right. You can use grid or other packages in order to use 
recursive kinds of subdivisions.

Uwe Ligges


> (Thanks!)
> 
> ______________________________________________
> 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.




More information about the R-help mailing list