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.

Hi Chris,
Have a look at color2D.matplot in the plotrix package (particularly the last example for more than one color range). I think you will have to precalculate your colors and pass that as the "cellcolors" argument.

Jim

______________________________________________
R-help@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.

Reply via email to