[R] Plot legend in margin

Greg Snow Greg.Snow at intermountainmail.org
Fri Aug 10 16:28:07 CEST 2007


Another couple of things to think about:

You could use the layout function to set up your multiple plots and
include an extra plotting area at the bottom to place the legend in.

If you stick with the solution below then the cnvrt.coords function from
the TeachingDemos package may be useful (will help you find the
coordinates relative to the last plot).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Daniel Brewer
> Sent: Friday, August 10, 2007 4:55 AM
> To: Lauri Nikkinen; r-help at stat.math.ethz.ch
> Subject: Re: [R] Plot legend in margin
> 
> Thanks.  That got me onto the right track.  Because it is a 
> multiplot and I wanted it along the bottom, I found that I 
> had to use par(xpd=NA) and then position it relative to the 
> last of the multiplots.  After a bit of trial and error I got there.
> 
> Thanks
> 
> Lauri Nikkinen wrote:
> > Very simple example:
> >  
> > opar <- par(mar = c(10, 4, 4, 4))
> > plot(1:10)
> > lines(1:10)
> > par(xpd=TRUE)
> > legend(4,-1.5,lty=1, col="black", legend="straigh line")
> > par(opar)
> >  
> > -Lauri
> 
> --
> **************************************************************
> Daniel Brewer, Ph.D.
> Institute of Cancer Research
> Email: daniel.brewer at icr.ac.uk
> **************************************************************
> 
> The Institute of Cancer Research: Royal Cancer Hospital, a 
> charitable Company Limited by Guarantee, Registered in 
> England under Company No. 534147 with its Registered Office 
> at 123 Old Brompton Road, London SW7 3RP.
> 
> This e-mail message is confidential and for use by the\ > ...{{dropped}}



More information about the R-help mailing list