[R] Axis label spanning multiple plots

Greg Snow Greg.Snow at imail.org
Tue Jun 2 18:54:37 CEST 2009


You will need to tell mtext something about where to position the text (at least until the esp package becomes available).  Sometimes using the adj argument gives a good enough result, if not then you will need to use the at argument, the grconvertY function (and grconvertX) is one way to find coordinates to use,
 you could use the top of the second figure region as the center of the text with something like:

> mtext('sample text', side=2, outer=TRUE, adj=0.5, at= grconvertY(1, from='nfc', to='ndc'))

Or use layout as has been suggested (but the grconvertY (and X) functions may helpful for variations on your second question).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Andre Nathan
> Sent: Monday, June 01, 2009 2:03 PM
> To: Greg Snow
> Cc: r-help at r-project.org
> Subject: Re: [R] Axis label spanning multiple plots
> 
> Hello
> 
> On Wed, 2009-05-27 at 13:38 -0600, Greg Snow wrote:
> > Create an outer margin (see ?par), then use mtext to put the title in
> the outer margin.
> 
> Sorry for taking that long to reply...
> 
> I created an outer margin with
> 
>   par(oma = c (0, 2, 0, 0))
> 
> and then did
> 
>   par(mfrow = c(2, 1))
>   plot(...)
>   plot(...)
>   mtext("title 1", side = 2, outer = T)
> 
> With that, the text "title 1" appears to the left of the second plot,
> and not to the left of both plots, centered between them, which is what
> I was trying to do. Is there a way to accomplish that (without manual
> text positioning, that is)?
> 
> Thanks,
> Andre
> 
> ______________________________________________
> R-help at r-project.org 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.




More information about the R-help mailing list