Thursday, February 11, 2010

Colors in R

Hello World,
R is a pretty wicked statistical analysis tool with great resources for plotting data. I use it on a regular basis and I'll use this blog to document notable finds along the way. This will hopefully help me find answers to previously encountered problems by taking a peek at the blog rather than fishing through my sea of bookmarks. Here is a short comment on colors in R.

colors() gives a list of all the available colors in R. It looks like this:
[1] "white" "aliceblue" "antiquewhite"
[4] "antiquewhite1" "antiquewhite2" "antiquewhite3"
[7] "antiquewhite4" "aquamarine" "aquamarine1"
[10] "aquamarine2" "aquamarine3" "aquamarine4"
.
.
[646] "wheat" "wheat1" "wheat2"
[649] "wheat3" "wheat4" "whitesmoke"
[652] "yellow" "yellow1" "yellow2"
[655] "yellow3" "yellow4" "yellowgreen"

The way to select a particular color is:
plot(x,y,col=color()[646])
or
plot(x,y,col="wheat")

Ciao!

No comments:

Post a Comment