Re: [R] plots: layout + subtitles

From: Paul Murrell <p.murrell_at_auckland.ac.nz>
Date: Mon 16 Oct 2006 - 18:59:56 GMT

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@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@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
R-help@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.
Received on Tue Oct 17 06:32:40 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 16 Oct 2006 - 21:30:10 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.