\Header{Palettes}{Color Palettes}
\alias{rainbow}{Palettes}
\alias{heat.colors}{Palettes}
\alias{terrain.colors}{Palettes}
\alias{topo.colors}{Palettes}
\alias{cm.colors}{Palettes}
\keyword{color}{Palettes}
\keyword{dplot}{Palettes}
\begin{Usage}
\begin{verbatim}
rainbow(n, s = 1, v = 1, start = 0, end = max(1,n - 1)/n, gamma = 1)
heat.colors(n)
terrain.colors(n)
topo.colors(n)
cm.colors(n)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{n}] the number of colors (\eqn{\ge 1}{>= 1}) to be in the palette.
\item[\texttt{s,v}] the ``saturation'' and ``value'' to be used to
complete the HSV color descriptions.
\item[\texttt{start}] the (corrected) hue in [0,1] at which the rainbow begins.
\item[\texttt{end}] the (corrected) hue in [0,1] at which the rainbow ends.
\item[\texttt{gamma}] the gamma correction, see \texttt{\Link{hsv}(.., gamma)}.
\end{ldescription}
\end{Arguments}
\begin{Description}
These functions create a vector of \texttt{n} ``contiguous'' colors.
Conceptually, all of these functions actually use (parts of) a line
cut out of the 3-dimensional color space, parametrized by
\texttt{\Link{hsv}(h,s,v, gamma)}, where \texttt{gamma}\eqn{=1}{} for the
\emph{foo}\texttt{.colors} function, and hence,
equispaced hues in RGB space tend to cluster at
the red, green and blue primaries.

Some applications such as contouring require a palette
of colors which do not ``wrap around'' to give a final
color close to the starting one.
With \texttt{rainbow}, the parameters \texttt{start} and \texttt{end} can be used
to specify particular subranges of hues.
The following values can be used when generating
such a subrange:
red=0, yellow=\eqn{\frac 1 6}{1/6}, green=\eqn{\frac 2 6}{2/6}, cyan=\eqn{\frac 3 6}{3/6}, blue=\eqn{\frac 4 6}{4/6} and magenta=\eqn{\frac 5 6}{5/6}.\end{Description}
\begin{Value}
A character vector, \texttt{cv}, of color names.  This can be used
either to create a user--defined color palette for subsequent
graphics by \texttt{\Link{palette}(cv)}, a \texttt{col=} specification
in graphics functions or in \texttt{par}.\end{Value}
\begin{SeeAlso}
\texttt{\Link{colors}}, \texttt{\Link{palette}},  \texttt{\Link{hsv}},
\texttt{\Link{rgb}}, \texttt{\Link{gray}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# A Color Wheel
piechart(rep(1,12), col=rainbow(12))

##------ Some palettes ------------
n <- if(.Device == "postscript") 64 else 16
## For screen, larger n may give color allocation problem
i <- 1:n
d <- n/20; dy <- 2*d; j <- n%/%4
plot(i,i+d, type='n', main=paste("color palettes;  n=",n))
rect(i-.5,     dy, i+.4,   j, col=rainbow(n, start=.7, end=.1))
text(2*j,    j+dy/4,		 "rainbow(n, start=.7, end=.1)")
rect(i-.5,   j+dy, i+.4, 2*j, col=heat.colors(n))
text(2*j,  2*j+dy/4,		 "heat.colors(n)")
rect(i-.5, 2*j+dy, i+.4, 3*j, col=terrain.colors(n))
text(2*j,  3*j+dy/4,		 "terrain.colors(n)")
rect(i-.5, 3*j+dy, i+.4, 4*j, col=topo.colors(n))
text(2*j,  4*j+dy/4,		 "topo.colors(n)")
rect(i-.5, 3*j+dy, i+.4, 4*j, col=cm.colors(n))
text(2*j,  4*j+dy/4,		 "cm.colors(n)")
\end{ExampleCode}
\end{Examples}

