[R] Problem with R colors

Sarah Goslee sarah.goslee at gmail.com
Mon Dec 9 23:21:23 CET 2013


Hi,

col=552 isn't the same as colors()[552] - I think the former is drawn
from your current palette, with recycling of indices. The default
color palette has only eight colors.

You need instead

col=colors()[552]

It's very difficult to get 20-30 readily distinguishable colors. You
might try the RColorBrewer package for smaller tasks, though.


Sarah


On Mon, Dec 9, 2013 at 5:12 PM, Katharine Miller <kmill117 at alaska.edu> wrote:
> Hello,
>
> I am having difficulty obtaining the correct colors in my R charts.
>
>> colors()[c(552, 254, 26)]
> [1] "red"   "green" "blue"
>
> But, if I specify col=552 in my barplot, I get gray bars.  Likewise,
> col=254 gives bright pink, and col=26 is a red-orange.   I get accurate
> results when I spell out the names, but I am making a pallet with 20- 30
> colors and it is a real pain to have to do that.  Can anyone help me figure
> out what I am doing wrong?
>
> Thanks

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list