Skip to content

Chart colors

4 messages · Katharine Miller - NOAA Federal, Michael Sumner, Peter Langfelder +1 more

#
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:

  
    
#
On Mon, Dec 9, 2013 at 2:08 PM, Katharine Miller - NOAA Federal
<katharine.miller at noaa.gov> wrote:
I believe there are two different color specifications. When you write
col=<number>, you get one of 8 "basic" colors: black, red, green,
blue, turquoise, magenta, yellow, and grey. See this example:

plot(c(1:30), pch = 21, bg = c(1:30), col = c(1:30))

 If the number is higher than 8, you get the (number-1) mod 8 + 1
color. That would explain why you get grey for 552, "bright pink"
(really magenta) for 254, and red for 26.

If you want to get the colors listed by colors(), simply specify col =
colors()[c(552, 254, 26)].

Add as many numbers to the 552, 254, 26 as you need.

Hope this helps,

Peter
#
Not reading the documentation for color specification? Integers do not specify offsets in the colors() table.

?par

If you do want offsets into the colors table, perhaps you should do just that?

..., col=colors()[ c( 552, 254, 26 )], ...

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Katharine Miller - NOAA Federal <katharine.miller at noaa.gov> wrote: