Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.LNX.4.64.0809161523550.3883@paninaro.stat-math.wu-wien.ac.at>
Date: 2008-09-16T13:26:20Z
From: Achim Zeileis
Subject: question in value-based color in image()
In-Reply-To: <b78ab8330809160553w2d5f46f7vf869b20032f95b1d@mail.gmail.com>

On Tue, 16 Sep 2008, M. wrote:

> Hello,
>
> I have a matrix A with value varying from -1 to 1.  I hope to use scaled
> color based on its value to produce an image of this matrix.
>
> Suppose I hope to label those data in [-1,-0.5] with blue, label those
> [-0.5,0.8] with light blue (tone is proportional to its value, e.g.
> rgb(1-tone, 1-tone, 1) where tone=abs(A)/0.5), and label those [0.8,1] with
> white.
>
> How can I use image() and rgb() to achieve this?  It would be great if I can
> have a color scale legend, too.

RGB is not the most convenient color space for doing such computations, 
HCL is color model that is quite useful and the package "vcd" provides 
some functions like diverge_hcl() for computing palettes based on HCL 
colors. See
   vignette("hcl-colors", package = "vcd")
   ?diverge_hcl

hth,
Z

> TIA,
> Chris
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>