[Rd] [R] color palette from red to blue passing white (shifted from R-help)
Achim Zeileis
Achim.Zeileis at wu-wien.ac.at
Wed Dec 5 12:29:53 CET 2007
Just a few small additions to what Paul already wrote:
> Achim and I have been looking at tidying up the colorspace package (see
> http://r-forge.r-project.org/projects/colorspace/) to fix a few
> inaccuracies, PLUS the possibility of declaring R's internal color space
> to be sRGB.
Also, we moved the color palettes out of "vcd" into "colorspace" so that
this is all in one place. That version is not on CRAN yet...but on
R-Forge.
> > AZ> levelplot(x, col.regions = diverg_hcl(16))
> >
> > Hmm, I would have recommended
> >
> > colorRampPalette(c('dark red','white','dark blue'),
> > space = "Lab")
> >
> > where the 'space = "Lab"' part also makes sure that a
> > "perceptually-based" space rather than RGB is used.
But that does not help you if your starting points are not balanced. "dark
red" and "dark blue" do not correspond to the same luminance coordinate
in HCL (or also LUV/LAB) space. As both use 139 in RGB, look at
R> dark <- RGB(c(139/255, 0, 0), c(0, 139/255, 0), c(0, 0, 139/255))
R> as(dark, "polarLUV")
L C H
[1,] 40.56124 136.40188 12.17395
[2,] 68.73912 106.38239 127.72353
[3,] 23.45176 94.89138 265.87278
^^^^^^^^
There are certainly diverging palettes in use with more serious problems,
but why not simply use the canned solution in "vcd" which avoids this
problem?
BTW: Some background information about the stuff we did for "vcd" is
available in
http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_c87
And, Ken, apologies for using bad terminology again...:-)
grx,
Z
More information about the R-devel
mailing list