[R] Positioning a legend via X and Y coordinates

Steve Murray smurray444 at hotmail.com
Wed May 6 19:08:03 CEST 2009


Dear R Users,

I'm able to display a legend using the following code:

> legend("topright", c("Simulation", "Observation"), fill=2:3, bty="n")

However, this causes the legend to be positioned too close to the bars in my barplot. I'd like to move the legend up slightly. I have been trying to determine the necessary values by trial and error to do this manually (by entering a coordinate) - however, I can't seem to get the legend to display! I must be off-limits, although I have tried a range of values.

I can do a temporary fix by doing locator(1), but I'd ideally like to learn how to determine the range of coordinate values 'available' within the graphics console in order to state the x and y values for legend positioning in the legend command. Is there an easy way to do this?

Thanks,

Steve




More information about the R-help mailing list