Re: [R] Dual colour ramps based on pos/neg values

From: Achim Zeileis <>
Date: Fri, 22 Apr 2011 12:26:31 +0200 (CEST)

On Fri, 22 Apr 2011, Jim Lemon wrote:

> On 04/22/2011 12:48 PM, Tyler Hayes wrote:
>> Hi Everyone:
>> I'm going a little nuts here and am hoping someone might have some
>> ideas to help out. Here is my problem:
>> I am using the calendarHeatMap function
>> (
>> to plot some values of percentages above or below a watermark. In
>> other words, I have a time series whose data can range arbitrarily
>> from -0.34 to +1.9, for example.
>> However, for the visualization to be effective, I need to be able to
>> distinguish conclusively where the division between positive and
>> negative takes place. My original thought was to just modify the
>> colorRampPalette function inputs to achieve the effect. Unfortunately,
>> because of the smooth blending, it washes out the middle. Not to
>> mention the middle of the colour range is not always zero.
>> What I would to do is concatenate two colour ranges such that:
>> bright red (max negative) -> dark red (min negative)
>> dark green (min positive) -> chartreuse (max positive)
>> I know, chartreuse. Not to mention the fact that the these ranges will
>> change with each dataset I apply. Now, believe me, I have tried
>> searches for colorramp range, positive, and so on, but can't seem to
>> find a smoking gun that will work with the function above. I came
>> across the ggplot package as well, which looks promising (book ordered
>> and en route), but I believe this function uses a different graphic
>> methodology.
> Hi Tyler,
> Have a look at the third example in the color2D.matplot function in the
> plotrix package.

See also ?diverge_hcl in the "colorspace" package. The underlying ideas are described in

   Achim Zeileis, Kurt Hornik, Paul Murrell (2009). Escaping RGBland:    Selecting Colors for Statistical Graphics. Computational Statistics &    Data Analysis, 53, 3259-3270. doi:10.1016/j.csda.2008.11.033

A preprint version is available from my web page.


> Jim
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
> mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 22 Apr 2011 - 10:36:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Apr 2011 - 10:40:32 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive