The gray (level) function returns different shades of gray, where level is a vector of numbers ranging from 0 to 1.? 0 is white and 1 is black and everything in between is a shade of gray. Is there a function that will let me choose two different colors?? For example, a 0 might be blue and 1 might be red and in between might be a mix. Jeffrey
Tena koe See the colorspace package. HTH .... Peter Alspach -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Jeffrey Joh Sent: Thursday, 26 January 2012 10:36 a.m. To: r-help at r-project.org Subject: [R] Gray levels The gray (level) function returns different shades of gray, where level is a vector of numbers ranging from 0 to 1.? 0 is white and 1 is black and everything in between is a shade of gray. Is there a function that will let me choose two different colors?? For example, a 0 might be blue and 1 might be red and in between might be a mix. Jeffrey ______________________________________________ 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. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.
Besides the package already recommended, the rainbow() function in base R has rudimentary capabilities of that type. Sarah On Jan 25, 2012 4:38 PM, "Jeffrey Joh" <johjeffrey@hotmail.com> wrote:> > The gray (level) function returns different shades of gray, where level is > a vector of numbers ranging from 0 to 1. 0 is white and 1 is black and > everything in between is a shade of gray. > > Is there a function that will let me choose two different colors? For > example, a 0 might be blue and 1 might be red and in between might be a mix. > > Jeffrey > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
The scales package? gradient_n_pal(c("red","white","blue"), c(0,0.5,1)) (seq(0,1,length=100)) HTH, baptiste On 26 January 2012 10:36, Jeffrey Joh <johjeffrey at hotmail.com> wrote:> > The gray (level) function returns different shades of gray, where level is a vector of numbers ranging from 0 to 1.? 0 is white and 1 is black and everything in between is a shade of gray. > > Is there a function that will let me choose two different colors?? For example, a 0 might be blue and 1 might be red and in between might be a mix. > > Jeffrey > > ______________________________________________ > 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.