[R] FW: color palettes

David L Carlson dcarlson at tamu.edu
Fri Aug 8 16:41:07 CEST 2014

I think your question is too vague to answer since we don't know what you are trying to do or how many colors you need. The easy answer is that you don't need to use rainbow() at all, just use color names:

mycolors <- c("red", "green", "blue", "violet")

and you will have one of each. For example, col=mycolors(2) will plot using green (and so will col="green"). There are lots of color names in R:

> length(colors(distinct=TRUE))
[1] 502

The longer answer is that there are many color palettes and ways of selecting, manipulating, and choosing colors. The built in functions include palettes such as rainbow, heat.colors, terrain.colors, topo.colors, cm.colors, and gray and ways of specifying colors (in addition to using names) including rgb, hsv, and hcl. In addition, there are several packages for creating color palettes including RColorBrewer, colortools, colorspace, and munsell.

David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of carol white
Sent: Friday, August 8, 2014 8:27 AM
To: r-help at r-project.org
Subject: [R] color palettes

Is there any way to take one color of each color family from a color palettes like rainbow? For ex, if there are different blues differentiated by intensity, hue etc, taking one of them. In this case, when using rainbow(n), then how to select 1 color of each family, for ex 1 blue, 1 red etc? It doesn't matter which intensity, hue etc is taken as long as 1 color from each family is taken.



	[[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list