[R] Centring titles for pairs of plots --- a solution.

Rolf Turner r.turner at auckland.ac.nz
Wed Nov 10 03:13:51 CET 2010


I have figured out a *slightly* less kludgy way of accomplishing
my goal.  Still a bit of a hack, but it works and seems to be
consistent across graphics devices.

Essentially it's this:  After the *first* plot in each row, do:

	U <- par()$usr
        XD <- diff(U[1:2])
        YD <- diff(U[3:4])
        text(U[1]+1.05*XD,U[3]+1.15*YD,labels=YR,adj=0,font=2,cex=1.5,xpd=NA)

where "YR" is the current value of the calendar year (e.g. 2004).  Note that
xpd=NA is necessary since the text is being placed outside the plotting region
and hence will not appear unless this parameter is properly set.

Hope this is of some use to someone besides my very good self. :-)

	cheers,

		Rolf Turner



More information about the R-help mailing list