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

Maxwell Reback mreback at gmail.com
Tue Oct 13 00:12:28 CEST 2009


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




More information about the R-help mailing list