Re: [R] How to set Color scale for color2D.matplot()

2011-07-22 Thread Jim Lemon

On 07/22/2011 01:42 AM, Youcheng Lin wrote:

Hello, everyone.

I am trying to show the correlation matrix using
color2D.matplot(). And I want to map (0,1) to (dark red to dark green).

But by default color2D.matplot() will map(min element of given matrix,
  max  element of given matrix) to (dark red to dark green).


Hi Youcheng,
If I understand your question, you have a correlation matrix with some 
values below zero, but you want to map only those values greater than or 
equal to zero as dark red - dark green. I'll assume that you want 
another set of colors for the negative values (purple to dark blue). 
Here's how:


corr.matrix-matrix(runif(100,-1,1),nrow=10)
cellcolors-matrix(NA,nrow=10,ncol=10)
cellcolors[corr.matrix = 0]-
 color.scale(corr.matrix[corr.matrix = 0],
 cs1=c(0.7,0),cs2=c(0,0.7),cs3=0)
cellcolors[corr.matrix  0]-
 color.scale(corr.matrix[corr.matrix  0],
 cs1=c(0.7,0),cs2=0,cs3=0.7)
color2D.matplot(corr.matrix,cellcolors=cellcolors,
 show.values=TRUE)

I've included the values in the example so that you can see that the 
positive and negative values are getting the correct colors.


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.


[R] How to set Color scale for color2D.matplot()

2011-07-21 Thread Youcheng Lin
Hello, everyone.

I am trying to show the correlation matrix using
color2D.matplot(). And I want to map (0,1) to (dark red to dark green).

But by default color2D.matplot() will map(min element of given matrix,
 max  element of given matrix) to (dark red to dark green).

Can anyone help me with this issue?
Thanks a lot!

Youcheng Lin


[[alternative HTML version deleted]]

__
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.