tags:

views:

162

answers:

1

I have an ultra short question about R

My aim is to assign a common title to a multi-panel plot generated using par, e.g.

par(mfrow=c(1,2))
plot(rnorm(1000))
plot(rnorm(1000))

So, something like "main" for the plot function, but extended to both plots. Is there a canonical way to do this?

Thanks for any answer :-)

+3  A: 

Use mtext with option outer:

set.seed(42)
oldpar <- par(mfrow=c(1,2), mar=c(3,3,1,1), oma=c(0,0,3,1))  ## oma creates space 
plot(cumsum(rnorm(100)), type='l', main="Plot A")
plot(cumsum(rnorm(100)), type='l', main="Plot B")
mtext("Now isn't this random", side=3, line=1, outer=TRUE, cex=2, font=2)
par(oldpar)
Dirk Eddelbuettel
You're my hero :-D
Thrawn
If only my wife said that more often.
Dirk Eddelbuettel
@dirk-eddelbuettel Your wife doesn't appreciate "multi-panel titles"?
Shane
Must. Not. Comment. Any. Further. ;-)
Dirk Eddelbuettel