Re: [R] ColorRamp different from ColorRampPalette
Try the rgb function in the grDevices library. pal.cr-colorRamp( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=rgb(pal.cr((0:40)/40),max=255)) Troy -- View this message in context: http://n4.nabble.com/ColorRamp-different-from-ColorRampPalette-tp889372p1692642.html Sent from the R help mailing list archive at Nabble.com. __ 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] ColorRamp different from ColorRampPalette
I try to use ColorRamp as ColorRampPalette (i.e. with the same gradient), but it seems there is a nuance that I've missed. pal.crp-colorRampPalette( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=pal.crp(40)) # is great But, using the same gradient with colorRamp is giving erratic colors. pal.cr-colorRamp( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=pal.cr((0:40)/40)) # is not great From the help : colorRamp returns a function that maps values between 0 and 1 to colors ...colors I guess taken from the gradient, but I don't get the gradient. Etienne -- View this message in context: http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23104641.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] ColorRamp different from ColorRampPalette
Look at the output of pal.cr((0:40)/40) Hadley On Fri, Apr 17, 2009 at 2:42 PM, Etienne B. Racine etienn...@gmail.com wrote: I try to use ColorRamp as ColorRampPalette (i.e. with the same gradient), but it seems there is a nuance that I've missed. pal.crp-colorRampPalette( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=pal.crp(40)) # is great But, using the same gradient with colorRamp is giving erratic colors. pal.cr-colorRamp( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=pal.cr((0:40)/40)) # is not great From the help : colorRamp returns a function that maps values between 0 and 1 to colors ...colors I guess taken from the gradient, but I don't get the gradient. Etienne -- View this message in context: http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23104641.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- http://had.co.nz/ __ 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.
Re: [R] ColorRamp different from ColorRampPalette
Thanks Hadley, Is it the solution you would recommend ? rgb(pal.cr((0:40)/40), maxColorValue=255) Etienne hadley wrote: Look at the output of pal.cr((0:40)/40) Hadley On Fri, Apr 17, 2009 at 2:42 PM, Etienne B. Racine etienn...@gmail.com wrote: I try to use ColorRamp as ColorRampPalette (i.e. with the same gradient), but it seems there is a nuance that I've missed. pal.crp-colorRampPalette( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=pal.crp(40)) # is great But, using the same gradient with colorRamp is giving erratic colors. pal.cr-colorRamp( c(blue, white, red), space = rgb) plot(rep(0,40),pch=16,col=pal.cr((0:40)/40)) # is not great From the help : colorRamp returns a function that maps values between 0 and 1 to colors ...colors I guess taken from the gradient, but I don't get the gradient. Etienne -- View this message in context: http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23104641.html Sent from the R help mailing list archive at Nabble.com. __ 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. -- http://had.co.nz/ __ 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. -- View this message in context: http://www.nabble.com/ColorRamp-different-from-ColorRampPalette-tp23104641p23105080.html Sent from the R help mailing list archive at Nabble.com. __ 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.