[R] legend position in "barplot"

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun Mar 20 19:31:55 CET 2011


On 20.03.2011 18:52, Hongwei Dong wrote:
> Hi, R users,
>
> I there a way that I can control the position of the legend while using
> "barplot" function?
>
> For example:
>
> a<-matrix(c(0,0,0.5,0.8,0.9,0.9),2,3)
> colnames(a)<-c("X","Y","Z")
> rownames(a)<-c("A","B")
> a
> barplot(a,width = 0.2,legend =
> TRUE,axes=FALSE,col=c("coral3","steelblue3"),beside=TRUE)
>
> In this case, the legend is too small, and I want to move it to the left.
> Thanks.

Yes, e.g.:

barplot(a, width = 0.2, legend = TRUE, axes = FALSE,
         col = c("coral3", "steelblue3"), beside = TRUE,
         args.legend = list(x="topleft"))

Uwe Ligges



>
> Regards
> Gary
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list