[R] Multiple use of par()

Hesen Peng hesen.peng at emory.edu
Fri Apr 3 23:14:12 CEST 2009


Hi all,

I created a plot function which used par(mfcol=c(2,1)) so that I could
have two plots together using just one command.

For exampe:

plot.foo <- function(data){
 par(mfcol=c(2,1))
 hist(data)
 plot(data)
}

Later I wanted to show 4 of these foo objects in the same picture. So
I used par(mfcol=c(2,2)) again at the beginning of the code like:

par(mfcol=c(2,2))
plot(foo.1)
plot(foo.2)
plot(foo.3)
plot(foo.4)

but this time the par() command inside of the functions seem to be
overwriting the par() command at the very begining. Can anyone please
give me some advise on dealing with this? I guess that I may either
need to change the way I plot foo, e.g. using some function rather
than par(), or use some parameters at the beginning. Thank you very
much,

Best wishes,



-- 
彭河森 Hesen Peng
http://hesen.peng.googlepages.com/




More information about the R-help mailing list