Re: [R] How to reverse colors in filled.contour?

From: Bert Gunter <gunter.berton_at_gene.com>
Date: Tue, 18 Mar 2008 15:14:15 -0700

from the Help file:

"color.palette: a color palette function to be used to assign colors in the plot."

so color = function(x)rev(heat.colors(x))

should do it.

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Ravi Varadhan
Sent: Tuesday, March 18, 2008 2:52 PM
To: r-help_at_stat.math.ethz.ch
Subject: [R] How to reverse colors in filled.contour?

Hi,  

I am plotting values of log(hazards ratio) as a function of two predictors, using the plotting function filled.contour(). Here is a simple simulated example of this:  

x <- seq(0,1, length=20)  

y <- seq(0,1, length=20)  

z <- outer(x,y, function(x,y) x^2 + y^2 )  

zmat <- matrix( rexp(n=400, rate = z+0.001), 20, 20)  

filled.contour(x, y, log(zmat), xlab="X", ylab="Y", color=heat.colors, main="log-Hazard ratios for different X & Y cutoffs")  

Here lower hazard-ratios are reddish and higher values are lighter. I would like to reverse the color palette "heat.colors" such that higher hazard ratios are reddish and lower values are lighter. Can any one suggest an easy way to do this?  

Also, suggestions on better ways to display this information would be greatly appreciated.  

Thanks very much.  

Best,

Ravi.



Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan_at_jhmi.edu

Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html  



 

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

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. Received on Tue 18 Mar 2008 - 22:16:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 18 Mar 2008 - 22:30:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive