[R] Centring titles for pairs of plots.

Jim Lemon jim at bitwrit.com.au
Wed Nov 10 08:29:35 CET 2010


On 11/10/2010 11:31 AM, Rolf Turner wrote:
>
> I would like to centre titles for pairs of plots in a 3-x-2
> array.  Each row of the array corresponds to a calendar year
> and I would like to have the year value centred between the
> two plots in the row, and just above their upper edges.
>
> I have attached an example in "demo.pdf" showing roughly
> what I want.  I managed to produce the example using
>
> mtext(outer=TRUE,side=3,line=<whatever>,text=YR,font=2)
>
> I got the appropriate (negative) values for "line" by trial-and-error
> experimentation. That's pretty kludgy, and the result only works for
> the screen graphics device with which I experimented.  If I switch to pdf()
> everything is out of whack.  I produced demo.pdf by plotting to the screen
> graphics device and then using dev.copy().
>
> Is there a non-kludgy way of accomplishing my objective?
>
Hi Rolf,
The getFigCtr function might also be helpful. It allows you to get any 
position within the figure region in user units. You would probably want 
to call:

getFigCtr(pos=c(0,0.9))

to place your title after drawing the right side plot in each row if I 
read your example correctly.

Jim



More information about the R-help mailing list