[R] Dual colour ramps based on pos/neg values
Jim Lemon
jim at bitwrit.com.au
Fri Apr 22 11:51:17 CEST 2011
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.
Jim
More information about the R-help
mailing list