[R] Dual colour ramps based on pos/neg values
Achim Zeileis
Achim.Zeileis at uibk.ac.at
Fri Apr 22 12:26:31 CEST 2011
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
>> (http://blog.revolutionanalytics.com/2009/11/charting-time-series-as-calendar-heat-maps-in-r.html)
>> 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.
Best,
Z
> Jim
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list