2008-07-22

Selecting and using colors in graphs

It is some time now since I came across a paper "Escaping RGBland: Selecting Colors for Statistical Graphics" by Zeileis et al. I have finnaly read (well I only parsed it since I get lost in the details about the color systems etc.) it and now it is time to try the new functions they implemeneted in the R package vcd. This is not the first work about colors in R. There is plenty of resources about this topic, sometimes even to much. At the end one does not know which approach to follow. I certainly liked the RColorBrewer package (see some examples here as well as original ColorBrewer site) as well as the work of Gentleman et al. (for example see figure 8 or at R graph gallery).

Zeileis et al. report about three functions for creation of color palletes: qualitative palette for coding categorical information via rainbow_hcl(), sequential palette via sequential_hcl() , and diverging palette via diverge_hcl(). The last two are amied at numerical and ordinal variables. The R Graphical Manual site shows 177 figures (at the time of writing) for the vcd package. I must admit that examples from vcd package did not attract me so much as those from RColorBrewer package.

Some R code to start with palletes in vcd package:
## Install the package
install.packages(pkg="vcd")

## Load the package
library(package="vcd")

## Check the vignette
vignette(topic="hcl-colors", package="vcd")
## --> this will open a PDF file with the code and examples
Btw. there are some excellent resources about graphics (mainly in relation with R):

5 comments:

Yihui Xie said...

Thanks for your recommendation (of both the paper and my wiki site); I'll read the paper some time later. By the way, you are not going to attend the "useR! 2008" conference?

Yihui Xie said...

I posted a comment just now, but it seems that it was gone?...

Gorjanc Gregor said...

Hi Yihui!

I moderate comments so that I get informed about each comment. I could use RSS for that, but I prefer moderation. At least I have some control over spammers.

Unfortunatelly, I will skip UseR! conference this year. I really need to finish my PhD.

Yihui Xie said...

I see :-)

Good luck!

Gorjanc Gregor said...

Jet another nice source is http://kuler.adobe.com for nice themes.