Skip to content
Prev 58532 / 398502 Next

Legend placement in barplot?

You can use locator()  nested within legend()
i.e.

plot(YourVariable)
legend(locator(1),legend="Your Legend")

Once you call this command it will display "Your Legend" in the place where 
you left clicked your mouse.  Beware that, as described in the documentation 
"...'locator' is only supported on screen devices such as 'X11','windows' 
and 'quartz'.  On other devices the call will do nothing"


Altrenativelly you can pass the exact coordinates of the position where you 
want the legend, instead of using locator
i.e.

plot(YourVariable)
x<-list(x=-91.76781, y=46.87375)
legend(x,legend="Your Legend")

I hope that this helps

Francisco