[R] Placing the legend 'dynamically'

Jim Lemon jim at bitwrit.com.au
Thu Mar 11 09:18:53 CET 2010


On 03/11/2010 01:36 AM, T.Wunder at stud.uni-heidelberg.de wrote:
> Hello,
>
> does anybody know which command to consider when I'm trying to plot a
> stacked barplot with a legend at the most empty portion of the graphic?
> I've searched for it, and somebody stated to use the labcurve-command,
> but I don't know how to produce stacked barplots with it.
> Is there any possibility to plot a legend box "dynamically" (= in an
> empty region) with the legend()-command?
> That would be helpful, because I'm already using this one.
>
Hi Tom,
As Eik mentioned, you can use the emptyspace function. This works most 
of the time, and there is also the locator function, used like this:

legend(locator(1),...)

allowing you to click where you want the legend to be placed.

Jim



More information about the R-help mailing list