[R] How to get legend outside of plot?

baptiste auguie ba208 at exeter.ac.uk
Wed Jan 14 10:21:41 CET 2009


Hi,

I think this is a very common question on this list. I've just created  
a page in the R wiki (inspired by https://stat.ethz.ch/pipermail/r-help/2007-May/132466.html) 
. With some suggestions and improvements, hopefully we can make a good  
reference for others to refer to in the future:

http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:legendoutside

Hope this helps,

baptiste

On 14 Jan 2009, at 01:27, Mike Williamson wrote:

>    I am creating a CDF plot function more user-friendly than any  
> default r
> function.  Depending upon the bimodality of the data (it is often  
> bimodal),
> or any other strange data trends, the points can end up gathering in  
> just
> about any corner of the plot.  So, when I add a legend, whether I  
> choose to
> add it in the bottom right, top left, or wherever, it will sometimes  
> end up
> putting the legend right on the data itself.  So, I tried to force the
> legend to certain data values (e.g., the largest in x & the smallest  
> in y,
> to "really" get the bottom right), but then this means most of the  
> legend is
> missing because it is outside of the "plot region".
>    How can I create a legend that is fully outside of the plot,  
> similar to
> what excel does by default, for example?
>
>                                                  Thanks!
>                                                      Mike
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag




More information about the R-help mailing list