[R] main title on splited windows.

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Jul 20 21:34:34 CEST 2007


On Fri, 2007-07-20 at 12:16 -0700, Milton Cezar Ribeiro wrote:
> Dear all,
> 
> How can I put a main title on the top of a windows?
> I would like put a title like "This is my for graphics" :-)

Create an outer margin to the plot and pop the title in there, e.g.:

## your data
v1<-sort(runif(50))
v2<-sin(v1*3.14)

## set up plotting region
## set oma to have a 2 line + a bit margin at the top, 
## 0 lines on other 3 sides
opar <- par(mfrow=c(2,2), oma = c(0, 0, 2.1, 0))
plot(v1,main="Sort V1")
plot(v2,main="Sin(V1)")
hist(v1,main="Histogram of V1")
boxplot(v1,v2, main="Box plot - v1 & v2")
## now add the title - use outer = TRUE to get it in correct place
## we use cex.main to increase the size a bit
title(main = "This is my for graphics", outer = TRUE, cex.main = 1.5)
## reset the plotting parameters
par(opar)

Is this what you wanted?

G

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson                 [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list