T.Wunder at stud.uni-heidelberg.de
2010-Mar-10 14:36 UTC
[R] Placing the legend 'dynamically'
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. Thank you, Kind regards, Tom
Hi tom, have a look at the emptyspace-function from the plotrix package. Looks like it does what you want?! Hth. T.Wunder at stud.uni-heidelberg.de schrieb:> 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. > > Thank you, > > Kind regards, Tom > > ______________________________________________ > 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.-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
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