An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080917/8b976ddd/attachment.pl>
creating rainbow gradients
9 messages · stephen sefick, Gillian Silver, Jorge Ivan Velez +4 more
plot(1:20, col=rainbow(20))
On Wed, Sep 17, 2008 at 4:58 PM, Gillian Silver <haettulegur at gmail.com> wrote:
Hi, how can I create a rainbow gradient in R? For example, let's say I have
a plot of y = x...and I want the plot to go from red -> orange -> yellow ->
green -> blue -> etc.
Right now, I know how to do something like go from red to blue, using the
plotrix library:
library(plotrix)
redToBlue <-
color.scale(x,redrange=c(0,1),greenrange=c(0,1),bluerange=c(0,1),extremes=c("red","blue"))
plot(x, y, col=redToBlue)
But I can't figure out how to make the colors a rainbow. (I don't understand
how the redrange, greenrange, and bluerange parameters in color.scale work.)
Could someone please help?
Thanks!
[[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.
Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080917/10af92e8/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080917/97241008/attachment.pl>
On Wed, Sep 17, 2008 at 3:11 PM, Gillian Silver <haettulegur at gmail.com> wrote:
What would I do if I have something like: x <- rnorm(1:1000) y <- rnorm(1:1000) z <- x + y and I want the rainbow to increase with z? (i.e., red for lowest z...all the way up to the last color in the rainbow for the highest z)
Do you mean something like the following? z <- rnorm(1000, sd = sqrt(2)) plot(z, col = rainbow(length(z), end = 5/6)[rank(z)], pch = 19)
On Wed, Sep 17, 2008 at 2:05 PM, stephen sefick <ssefick at gmail.com> wrote:
plot(1:20, col=rainbow(20)) On Wed, Sep 17, 2008 at 4:58 PM, Gillian Silver <haettulegur at gmail.com> wrote:
Hi, how can I create a rainbow gradient in R? For example, let's say I
have
a plot of y = x...and I want the plot to go from red -> orange -> yellow
->
green -> blue -> etc. Right now, I know how to do something like go from red to blue, using the plotrix library: library(plotrix) redToBlue <-
color.scale(x,redrange=c(0,1),greenrange=c(0,1),bluerange=c(0,1),extremes=c("red","blue"))
plot(x, y, col=redToBlue) But I can't figure out how to make the colors a rainbow. (I don't
understand
how the redrange, greenrange, and bluerange parameters in color.scale
work.)
Could someone please help?
Thanks!
[[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. -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
[[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.
On second thought, this is more likely to be what you're looking for... library(rgl) x <- rnorm(1000) y <- rnorm(1000) z <- x + y plot3d(x, y, z, col = rainbow(1000, end = 5/6)[rank(z)], size = 3) On Wed, Sep 17, 2008 at 4:06 PM, Kingsford Jones
<kingsfordjones at gmail.com> wrote:
On Wed, Sep 17, 2008 at 3:11 PM, Gillian Silver <haettulegur at gmail.com> wrote:
What would I do if I have something like: x <- rnorm(1:1000) y <- rnorm(1:1000) z <- x + y and I want the rainbow to increase with z? (i.e., red for lowest z...all the way up to the last color in the rainbow for the highest z)
Do you mean something like the following? z <- rnorm(1000, sd = sqrt(2)) plot(z, col = rainbow(length(z), end = 5/6)[rank(z)], pch = 19)
On Wed, Sep 17, 2008 at 2:05 PM, stephen sefick <ssefick at gmail.com> wrote:
plot(1:20, col=rainbow(20)) On Wed, Sep 17, 2008 at 4:58 PM, Gillian Silver <haettulegur at gmail.com> wrote:
Hi, how can I create a rainbow gradient in R? For example, let's say I
have
a plot of y = x...and I want the plot to go from red -> orange -> yellow
->
green -> blue -> etc. Right now, I know how to do something like go from red to blue, using the plotrix library: library(plotrix) redToBlue <-
color.scale(x,redrange=c(0,1),greenrange=c(0,1),bluerange=c(0,1),extremes=c("red","blue"))
plot(x, y, col=redToBlue) But I can't figure out how to make the colors a rainbow. (I don't
understand
how the redrange, greenrange, and bluerange parameters in color.scale
work.)
Could someone please help?
Thanks!
[[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. -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
[[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.
On Wed, Sep 17, 2008 at 3:58 PM, Gillian Silver <haettulegur at gmail.com> wrote:
Hi, how can I create a rainbow gradient in R? For example, let's say I have a plot of y = x...and I want the plot to go from red -> orange -> yellow -> green -> blue -> etc.
Why would you want to? See http://epub.wu-wien.ac.at/dyn/openURL?id=oai:epub.wu-wien.ac.at:epub-wu-01_c87 for some better alternatives. Hadley
On 17/09/2008 4:58 PM, Gillian Silver wrote:
Hi, how can I create a rainbow gradient in R? For example, let's say I have
a plot of y = x...and I want the plot to go from red -> orange -> yellow ->
green -> blue -> etc.
Right now, I know how to do something like go from red to blue, using the
plotrix library:
library(plotrix)
redToBlue <-
color.scale(x,redrange=c(0,1),greenrange=c(0,1),bluerange=c(0,1),extremes=c("red","blue"))
plot(x, y, col=redToBlue)
But I can't figure out how to make the colors a rainbow. (I don't understand
how the redrange, greenrange, and bluerange parameters in color.scale work.)
Could someone please help?
Others have pointed you to the rainbow() function; you should also look at colorRamp, in case you want to construct your own colour sequence. Duncan Murdoch
Gillian Silver wrote:
Hi, how can I create a rainbow gradient in R? For example, let's say I have
a plot of y = x...and I want the plot to go from red -> orange -> yellow ->
green -> blue -> etc.
Right now, I know how to do something like go from red to blue, using the
plotrix library:
library(plotrix)
redToBlue <-
color.scale(x,redrange=c(0,1),greenrange=c(0,1),bluerange=c(0,1),extremes=c("red","blue"))
plot(x, y, col=redToBlue)
But I can't figure out how to make the colors a rainbow. (I don't understand
how the redrange, greenrange, and bluerange parameters in color.scale work.)
Hi Gillian, Try: my.rainbow<-color.scale(x,c(1,1,0,0),c(0,1,1,0),c(0,0,0,1)) The "extremes" argument takes precedence over your color ranges Jim