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
[apologies for possible multiple posting]
Hi Joris
great suggestion! I never thought to use layout() in this way.
If I have
postscript(file="~/f.ps",width=5,height=8)
nf <- layout(matrix(
c(00,01,00,02,00,03,
04,05,00,06,00,07,
00,00,00,00,00,00,
08,09,00,10,00,11,
00,00,00,00,00,00,
12,13,00,14,00,15,
00,00,00,00,00,00,
16,17,00,18,00,19),8,6,byrow=TRUE), c(1,4,
1,4, 1,4), c(1,4,1,4,1,4,1,4), TRUE)
layout.show(nf)
dev.off()
This is exactly what I want.
I hadn't appreciated that the empty rows and columns would be clear.
How best to put text in boxes 1,2,3 (that used to be main() and
vertical text in
boxes 4,8,12,16 (that used to be ylab)?
best wishes
Robin
On 10 Jul 2006, at 10:27, Joris De Wolf wrote:
> Check
> ?layout
>
> It gives you more flexibility than
> par(mfrow=c(a,b))
>
> For instance, you can define your margins between the graphs as
> cells in the layout without filling them by a plot.
>
> Joris
>
>
> Robin Hankin wrote:
>> Hi
>> I'm having difficulty with a multiple plot.
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743