[R] legend position in barplot

Paul Murrell pm254 at medschl.cam.ac.uk
Fri Aug 27 12:39:44 CEST 1999


hi


---SNIP---
Can anyone help me with how to change the position of the legend
in "barplot"? It keeps obscuring my data :-(
---SNIP---


(i assume you are specifying legend.text in the barplot function)

you can use the legend() function to put your own legend on your plot.  for
example ...

x <- barplot(rbind(1:10, 10:1), beside=T)
legend(mean(x),10,c("group1", "group2"),fill=c("red", "yellow"))


NOTE that you have to find out what x-axis scale has been set by barplot() -
i've done that by getting the x-locations of the bars.  another way to do it
would be to use par("usr")[1:2]

hope that helps

paul


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list