11 Working with colors in R
You can find built-in named colors in R by using colors() function. There are 657 named colors.
You can see the color code here http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf
More color palette:
There are 3 types of palette
Sequential: represents range of values, for example age groups, temperature et
Qualitative: represents different groups of values for example, one color shade for each political parties, color of each county in the map
Diverging: Show high and low values, for example, positive and negative approval rating on a map where each extreme values get dark shades and middle lighter color representing neutral values
There is an R package for color brewer - "RColorBrewer". Install the package if not present in your R.
Shows all named palettes from RColorBrewer package
Display color from a named palette
Before you use the color brewer palette, save the palette in a vector
> x = c(4, 5, 2, 3, 10)
> blues = brewer.pal(5, "Blues")
> barplot(x, col = blues)