I suggest to add a new function to create a vector of
n ``contiguous'' colors with tails in two colors.
This function is similar to `cm.colors' but the colors
can be choosen by hsv values.
This function could be used e.g. as alternative to
the default ``col.regions'' in `levelplot'.
Perhaps the arguments in the following code could be
simplified.
Wolfram Fischer
#--- twotailed.colors.R
twotailed.colors <-
function(
n = 7 # number of colors to be in the palette
, n5 = n %% 2 # number of colors between the two tails
, h1 = 0.02 # 0|1 = rot
, h2 = 0.15 # 0.7 = blau, 0.15 = samtgelb, 0.35 = grĂ¼n
, s0 = 1 # saturation: begin and end
, s5 = 1/n*1.4 # saturation: in the middle
, v0 = 1 # value: begin and end
, v5 = 1 # value: in the middle
, s01 = s0 # beginning saturation of first tail
, s02 = s0 # ending saturation of second tail
, s51 = s5 # middle saturation on of first tail
, s52 = s5 # middle saturation on of second tail
, v01 = v0 # beginning value of first tail
, v02 = v0 # ending value of second tail
, v51 = v5 # middle value on of first tail
, v52 = v5 # middle value on of second tail
, n.tail = ( n - n5 ) %/% 2
# number of colors in each tail
, s1 = seq( s01, s51, length = n.tail )
, s2 = seq( s52, s02, length = n.tail )
, v1 = seq( v01, v51, length = n.tail )
, v2 = seq( v52, v02, length = n.tail )
){
c( hsv( h1, s1, v1 )
, rep( hsv( h1, round(s5,0), v5 ), n5 )
, hsv( h2, s2, v2 )
)
}
#--- twotailed.colors.Rd
\name{twotailed.colors}
\alias{twotailed.colors}
\title{Two tailed color palette}
\description{
Create a vector of \code{n} ``contiguous'' colors
with tails in two colors.
}
\usage{
twotailed.colors( n = 7, n5 = n %% 2, h1 = 0.02, h2 = 0.15
, s0 = 1, s5 = 1/n*1.4, v0 = 1, v5 = 1
, s01 = s0, s02 = s0, s51 = s5, s52 = s5
, v01 = v0, v02 = v0, v51 = v5, v52 = v5
, n.tail = ( n - n5 ) %/% 2
, s1 = seq( s01, s51, length = n.tail )
, s2 = seq( s52, s02, length = n.tail )
, v1 = seq( v01, v51, length = n.tail )
, v2 = seq( v52, v02, length = n.tail )
)
}
\arguments{
\item{n}{ number of colors to be in the palette.}
\item{n5}{ number of colors between the two tails.}
\item{h1,h2}{values in the range \code{[0,1]} for the
``hue'' of the color of each tail, e.g.:
0 for red,
0.15 for yellow,
0.35 for green,
0.7 for blue.}
\item{s0}{ saturation: begin and end.}
\item{s5}{ saturation: in the middle.}
\item{v0}{ value: begin and end.}
\item{v5}{ value: in the middle.}
\item{s01}{ beginning saturation of the first tail.}
\item{s02}{ ending saturation of the second tail.}
\item{s51,s52}{ middle saturation on of the first and the second tail.}
\item{v01}{ beginning value of the first tail.}
\item{v02}{ ending value of the second tail.}
\item{v51,v52}{ middle value on of the first and the second tail.}
\item{n.tail}{ number of colors in each tail.}
\item{s1,s2}{ vector of saturations of first and the second tail.}
\item{v1,v2}{ vector of values of the first and the tail.}
}
\details{
}
\value{A character vector, \code{cv}, of color names. This can be used
either to create a user--defined color palette for subsequent
graphics by \code{\link{palette}(cv)}, a \code{col=} specification
in graphics functions or in \code{par}.
}
\seealso{
\code{\link{cm.colors}},
\code{\link{colors}}, \code{\link{palette}}, \code{\link{hsv}},
\code{\link{rgb}}, \code{\link{gray}} and \code{\link{col2rgb}} for
translating to RGB numbers.
}
\author{
Wolfram Fischer
}
\examples{
twotailed.colors(12)
twotailed.colors(24,12)
showcolors( twotailed.colors(24,12) )
}
\keyword{color}
\keyword{dplot}
#---