[R] par(mfrow,mai) and multiple plot problem

Robin Hankin
Mon, 10 Jul 2006 09:09:52 -0000

Hi

I'm having difficulty with a multiple plot.  What I want is 12
plots, all of which are the same size and shape, differing
only in colour.  Each one is a square, so there is an asp=1
in the plot call.  I'm working in an Sweave environment so I
am free to choose the height and width of the plot.

I want the columns to be labelled at  the head (here t=1,2,3)
and the rows to be labelled at the left hand side (here an animal),

I don't want axes.

I want the plots to occupy the majority of the area of the output
postscript.

I want the vertical distance between the plots to be the
same as the horizontal distance between the plots (not critical
but would be nice).

Can anyone help me with these requirements?

My best attempt is below, but it is no good because the
ylab argument that I'm trying to use for the row labelling
gets clipped.  Also, I can't get my horizontal spacing
to be equal to my vertical spacing (although the code
below isn't _too_ bad).





f <- function(...){
   jj <- expand.grid(1:10,1:10)
   colnames(jj) <- c("","")
   par(mai=rep(0,4)+0.2)
   plot(jj,pch=16,asp=1, axes=FALSE, ...)
}


postscript(file="~/f.ps",width=5,height=7)
par(mfrow=c(4,3))
f(main="t=1",ylab="fish")
f(main="t=2")
f(main="t=3")

f(ylab="dog")
f()
f()

f(ylab="slug")
f()
f()

f(ylab="pig")
f()
f()

dev.off()


--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743