[R] plots: layout + subtitles
Paul Murrell
p.murrell at auckland.ac.nz
Mon Oct 16 20:59:56 CEST 2006
Hi
Marie-Pierre Sylvestre wrote:
> Hello,
>
> I want to create a figure that consists of a collection of 16 graphs on
> 4 rows. I am using
>
> nf <- layout(matrix(seq(1,16), 4,4, byrow=TRUE), respect=TRUE)
> boxplot(...
>
> to create the layout of my 16 graphs. It works really well. However, I'd
> like to add sub-titles that would apply to each row of 4 graphs. More
> specifically, I'd like to have something like:
>
> subtitle 1 (centered)
> graph 1 graph 2 graph 3 graph 4
> subtitle 2 (centered)
> graph 5 graph 6 graph 7 graph 8
> subtitle 3 (centered)
> graph 9 graph 10 graph 11 graph 12
> subtitle 4 (centered)
> graph 13 graph 14 graph 15 graph 16
>
> in the same figure, to be saved as a ps file.
How about ...
lmat <- rbind(c(0, 17, 17, 0),
1:4,
c(0, 18, 18, 0),
5:8,
c(0, 19, 19, 0),
9:12,
c(0, 20, 20, 0),
13:16)
layout(lmat, respect=TRUE, widths=rep(5, 4), heights=rep(c(1, 5), 4))
# layout.show(20)
opar <- par(cex=0.5, mar=c(4, 4, 1, 1))
for (i in 1:16)
plot(i)
par(mar=rep(0, 4))
for (i in 1:4) {
plot.new()
text(0.5, 0.5, paste("Sub-title", i))
}
par(opar)
> Can somebody help?
> I hope this question is not redundant, but I have not found information
> on this on the R mailing lists.
>
> I use R 2.3.1 on Linux FC5.
>
> Thank you in advance.
>
> Marie-Pierre Sylvestre
> PhD student, McGill University
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/
More information about the R-help
mailing list