[R] Placing legends

Jason Turner jasont at indigoindustrial.co.nz
Sun Oct 5 04:02:48 CEST 2003


Doug Bourne wrote:

> I'm trying to automate making a bunch of figures and I need a way to 
> automate legend position.  As I understand it the legend is placed based 
> on coordinates.  I don't know before hand what the coordinates are going 
> to be.  On one graph my y axis might go from -50 to -10.  On another it 
> might go from 0 to 180.
> 

Easiest way is to:
1) make your plot.
2) change to co-ordinate system.
3) add the legend.

plot(...some stuff...)
par(usr=c(0,1,0,1))
# say you want you legend at 60% across, 80% up.
legend(x=0.6,y=0.8,...legend stuff...)

?par has this.  Check out "usr"

Cheers

Jason

-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
jasont at indigoindustrial.co.nz




More information about the R-help mailing list