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. TIA, Chris [[alternative HTML version deleted]]
Martin Maechler
2008-Sep-16 09:58 UTC
[Rd] WRONG mailing list - Re: question in value-based color in image()
Please do use R-help, (not R-devel) for such questions.>>>>> "M" == M <glycob at gmail.com> >>>>> on Mon, 15 Sep 2008 22:42:22 -0400 writes:M> Hello, I have a matrix with value varying from -1 to 1. M> I hope to use scaled color based on its value to produce M> an image of this matrix. M> Suppose I hope to label those data in [-1,-0.5] with M> blue, label those [-0.5,0.8] with light blue (tone is M> proportional to its value) and label those [0.8,1] with M> white. M> How can I use image() and rgb() to achieve this? It M> would be great if I can have a color scale legend, too. M> TIA, Chris M> [[alternative HTML version deleted]]
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