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-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of carol white
Sent: Friday, August 8, 2014 8:27 AM
To: r-help@r-project.org
Subject: [R] color palettes

Hi,
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.


Thanks

Carol

        [[alternative HTML version deleted]]

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

Reply via email to