[R] Chart colors
Michael Sumner
mdsumner at gmail.com
Mon Dec 9 23:56:11 CET 2013
Those numbers that you pass to col = ... correspond to the current
sessions palette, not to the names of colors() that R knows about. You
can either set up your own palette:
## see current palette
palette()
[1] "black" "red" "green3" "blue" "cyan" "magenta" "yellow"
[8] "gray"
## set up new palette
palette(grey(seq(0, 0.9, length = 25)))
plot(1:25, col = 1:25, pch = 16)
or give a direct set of colours to col = as either character names or
hex values.
See "Color Specification" under ?par and ?palette for an overview and
pointers to other functions.
Cheers, MIke.
On Tue, Dec 10, 2013 at 9:08 AM, Katharine Miller - NOAA Federal
<katharine.miller at noaa.gov> 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
>
> [[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.
--
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com
More information about the R-help
mailing list