[R] Legend position outside

Greg Snow Greg.Snow at imail.org
Fri Apr 11 20:19:24 CEST 2008


Yes, here is one way:

> plot(1:10, pch=1:2)
> par(xpd=NA)
> tmp.u <- par('usr')
> legend(tmp.u[1], tmp.u[4], xjust=0, yjust=0, c('a','b'), pch=1:2)
> 

You will probably want to increase the margins for a real case.  See
?par and the 'xpd' entry for details on the clipping and ?legend for
more details on creating the legend.

Hope this helps,

-- 
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 Edwin Sendjaja
> Sent: Friday, April 11, 2008 1:01 PM
> To: r-help at r-project.org
> Subject: [R] Legend position outside
> 
> Hello,
> 
> Is it possible to get the legend box outside the graphic?
> 
> 
> Kind regards,
> 
> Edwin
> 
> ______________________________________________
> 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