On Jul 2, 2011, at 02:14 , Marc Schwartz wrote:
> 
> 
> Alternatively, You can use legend() separately to add the legend to the 
> barplot in the fashion that you desire.
> 
> Thus:
> 
>  barplot(mat)
> 
>  legend("topright", legend = rownames(mat), 
>         fill = grey.colors(nrow(mat)))
> 

Yup. One thing: I'd future-proof it, making double-damn-sure that it is 
actually the same colors in the plot and the legend by going

clr <- grey.colors(nrow(mat))
barplot(mat, col = clr)
legend("topright", legend = rownames(mat), fill = clr) 


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd....@cbs.dk  Priv: pda...@gmail.com

______________________________________________
R-help@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.

Reply via email to