[Rd] [R] color palette from red to blue passing white (shifted from R-help)

Paul Murrell p.murrell at auckland.ac.nz
Tue Dec 4 20:53:10 CET 2007


Hi

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.

I have started an RFC on the r-developer site
(http://developer.r-project.org/sRGB-RFC.html) to discuss some possible
changes to the core engine and add-on packages.

One of the issues will be consolidating some of the double-ups (e.g.,
hcl() in base and the counterpart in package 'colorspace';  I did not
even know about convertColor()!).

Ideally, we would have only one copy of the conversions between the
various colorspaces (probably C code, then the various R-level front
ends can all just run off the same internal code).

A lot of these conversions exist now in 'colorspace', but as Thomas
pointed out, the S4-ness of 'colorspace' is a problem for making these
conversions part of base R.

Paul


Martin Maechler wrote:
>>>>>> "AZ" == Achim Zeileis <Achim.Zeileis at wu-wien.ac.at>
>>>>>>     on Tue, 4 Dec 2007 05:08:51 +0100 (CET) writes:
> 
>     AZ> On Mon, 3 Dec 2007, jim holtman wrote:
> 
>     >> see if this is what you need:
>     >> 
>     >> require(lattice) x <- matrix(1:100,10)
>     >> levelplot(x,col.regions=colorRampPalette(c('dark
>     >> red','white','dark blue')))
> 
>     AZ> Instead of colorRampPalette(), you could also use
>     AZ> diverge_hcl() in package "vcd" to get a
>     AZ> perceptually-based version, e.g.,
> 
>     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.
> 
> I think the functions colorRamp() and (even more)
> colorRampPalette()  are very nice, part of "standard R" and 
> still not known and used enough.
> Note that they are based on 'convertColor()' and other color
> space functionality in R all of which deserve more usage 
> in my oppinion and also in my own code ! ;-) 
> 
> Package 'vcd' (and others) use package 'colorspace', 
> and I have wondered in the past if these color space computations
> should not be merged into to standard R (package 'grDevices').
> But that's really a topic for another thread, on R-devel, not R-help..
> 
> Martin Maechler, ETH Zurich
> 
> 
>     >> On Dec 3, 2007 5:41 PM, Linda Smith
>     >> <lsmithingm at gmail.com> wrote: > Hi All,
>     >> >
>     >> > I am looking for a color palette like this: >
>     >> http://www.ncl.ucar.edu/Applications/Images/h_long_5_lg.png
>     >> >
>     >> > I think I found out how some time ago (something like
>     >> Colors[1:n]), but when > I now wanna use it, I could not
>     >> remember how I did it.
>     >> >
>     >> > Does anyone know which package I could use?
>     >> >
>     >> > Many thanks!
>     >> >
>     >> > Linda
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-devel mailing list