[R] Using the legend function inside a bar chart error.bars function

Jim Lemon jim at bitwrit.com.au
Sun Oct 26 12:36:09 CET 2008

Sarah Vandome wrote:
> Hello,
> I am just starting out using R on my Uni course. I have been given a function to work with that adds error bars to a bar chart. I want to add a legend and have been trying to amend the code in the function error.bars (see below) so it automatically places a legend on the chart. It does this, but the legend is sitting over the top of one of my data columns. I need the function to decide where best to place the legend, depending on where the chart bar data and error bars are located. Is it possible to do this?
Hi Sarah,
The "emptyspace" function in the plotrix package can find the empty 
space on a bar chart, but would need a little modification to avoid 
error bars. You could feed it the bar heights plus the error bars, but 
that might not be automatic enough.


More information about the R-help mailing list