[R] barplot colors
jfearon at stanford.edu
Mon Jul 25 01:50:11 CEST 2011
In barplot(height, col = ...), the col = vector recycles so that the
same colors are used for each bar. I would like to use different colors
in different bars (corresponding to another piece of information, here,
the region of the country being represented).
x = matrix(c(5,2,3,1),nrow=2)
will draw two bars with two segments each, but each colored red and
black rather than red and black for the first bar, then green and blue
for the second.
I see in the archives that someone asked this question before, and got a
single reply (as far as I could tell) suggesting that s/he forget
barplot and use rect(). That's kind of a pain, so I'm wondering if
there is any simpler way of tricking barplot() into doing this.
More information about the R-help