[R] how to plot a nice legend?

Duncan Murdoch murdoch.duncan at gmail.com
Sat Feb 11 12:27:03 CET 2012


On 12-02-10 3:45 PM, Jonas Stein wrote:
> i'd like to plot a legend in my diagram. The diagram will be included
> in a TikZ LaTeX document later.
>
> I tried the legend() function, but
> - it can not find a good place it self where the legend fits
>    and playing around with coordinates and scaling consumes a lot time
>
> - standard settings for the text need adjustment
>    (linespacing is quite large and so on)
>
> Is there an alternative to legend()?
>
> Is it possible to place the legend() outside of the plot area?
>
> Kind regards,
>

There are various alternatives available; you can also write your own, 
by modifying the standard one.

Generally there are lots of possibilities for customizing within the 
standard one; e.g. y.intersp will affect the line spacing, using a 
negative value for inset (together with xpd=NA) will allow the legend to 
be moved outside the plot.

Duncan Murdoch



More information about the R-help mailing list