Skip to content
Prev 176078 / 398503 Next

Multiple use of par()

Hesen Peng-2 wrote:
Your example starts fine, but does not run because is it unclear what foo.1
etc. means. Please really post complete examples, chances are higher you get
a reasonable answer.

Reading between the lines, I suspect that you mixed up the concepts of
trellis plots with those of standard plot(). I think you believed that your
function returns the plot object, which is approximately true for trellis
where you could use a list of graphics objects and print() or plot() these
later in a given arrangement with split().

As an easy solution with standard graphics, I suggest the not-so-elegant one
below. You should probably adjust the margins a bit to make clear that
graphs are pairs.

Dieter

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


par(mfcol=c(4,2))
plot.foo(data)
plot.foo(data) # Use other data here
plot.foo(data)
plot.foo(data)