From ligges at statistik.tu-dortmund.de  Tue Sep 16 12:00:09 2008
From: ligges at statistik.tu-dortmund.de (Uwe Ligges)
Date: Tue, 16 Sep 2008 12:00:09 +0200
Subject: [Rd] question in value-based color in image()
In-Reply-To: <b78ab8330809151942p19928d51p779e25904e7f46cd@mail.gmail.com>
References: <b78ab8330809151942p19928d51p779e25904e7f46cd@mail.gmail.com>
Message-ID: <48CF83A9.8010208@statistik.tu-dortmund.de>



M. wrote:
> Hello,
> 
> I have a matrix 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) 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.


1. This is a message for R-help (if at all), definitely not for R-devel!
2. Have you read ?image ?

Anyway, example:

image(matrix(c(-1, -0.6, -0.4, 1), ncol = 2),
       breaks = c(-1, -0.5, 0.8, 1),
       col = c("blue", "lightblue", "white"))

Uwe Ligges




> TIA,
> Chris
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] question in value-based color in image()
Uwe Ligges