The R Project SVN R

Rev

Rev 61153 | Rev 76276 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61153 Rev 61168
Line 12... Line 12...
12
\title{Color Palettes}
12
\title{Color Palettes}
13
\description{
13
\description{
14
  Create a vector of \code{n} contiguous colors.
14
  Create a vector of \code{n} contiguous colors.
15
}
15
}
16
\usage{
16
\usage{
17
rainbow(n, s = 1, v = 1, start = 0, end = max(1,n - 1)/n, alpha = 1)
17
rainbow(n, s = 1, v = 1, start = 0, end = max(1, n - 1)/n, alpha = 1)
18
heat.colors(n, alpha = 1)
18
heat.colors(n, alpha = 1)
19
terrain.colors(n, alpha = 1)
19
terrain.colors(n, alpha = 1)
20
topo.colors(n, alpha = 1)
20
topo.colors(n, alpha = 1)
21
cm.colors(n, alpha = 1)
21
cm.colors(n, alpha = 1)
22
}
22
}
23
\arguments{
23
\arguments{
24
  \item{n}{the number of colors (\eqn{\ge 1}) to be in the
24
  \item{n}{the number of colors (\eqn{\ge 1}) to be in the
25
    palette.}
25
    palette.}
26
  \item{s,v}{the \sQuote{saturation} and \sQuote{value} to be used
26
  \item{s, v}{the \sQuote{saturation} and \sQuote{value} to be used
27
    to complete the HSV color descriptions.}
27
    to complete the HSV color descriptions.}
28
  \item{start}{the (corrected) hue in [0,1] at which the rainbow
28
  \item{start}{the (corrected) hue in [0,1] at which the rainbow
29
    begins.}
29
    begins.}
30
  \item{end}{the (corrected) hue in [0,1] at which the rainbow ends.}
30
  \item{end}{the (corrected) hue in [0,1] at which the rainbow ends.}
31
  \item{alpha}{the alpha transparency, a number in [0,1], see argument
31
  \item{alpha}{the alpha transparency, a number in [0,1], see argument
32
    \code{alpha} in \code{\link{hsv}}.}
32
    \code{alpha} in \code{\link{hsv}}.}
33
}
33
}
34
\details{
34
\details{
35
  Conceptually, all of these functions actually use (parts of) a line
35
  Conceptually, all of these functions actually use (parts of) a line
36
  cut out of the 3-dimensional color space, parametrized by
36
  cut out of the 3-dimensional color space, parametrized by
37
  \code{\link{hsv}(h,s,v)}, and hence,
37
  \code{\link{hsv}(h, s, v)}, and hence
38
  equispaced hues in RGB space tend to cluster at
38
  equispaced hues in RGB space tend to cluster at
39
  the red, green and blue primaries.
39
  the red, green and blue primaries.
40
 
40
 
41
  Some applications such as contouring require a palette
41
  Some applications such as contouring require a palette
42
  of colors which do not wrap around to give a final
42
  of colors which do not wrap around to give a final
Line 60... Line 60...
60
  \code{\link{col2rgb}} for translating to RGB numbers.
60
  \code{\link{col2rgb}} for translating to RGB numbers.
61
}
61
}
62
\examples{
62
\examples{
63
require(graphics)
63
require(graphics)
64
# A Color Wheel
64
# A Color Wheel
65
pie(rep(1,12), col=rainbow(12))
65
pie(rep(1, 12), col = rainbow(12))
66
 
66
 
67
##------ Some palettes ------------
67
##------ Some palettes ------------
68
demo.pal <-
68
demo.pal <-
69
  function(n, border = if (n < 32) "light gray" else NA,
69
  function(n, border = if (n < 32) "light gray" else NA,
70
           main = paste("color palettes;  n=",n),
70
           main = paste("color palettes;  n=", n),
71
           ch.col = c("rainbow(n, start=.7, end=.1)", "heat.colors(n)",
71
           ch.col = c("rainbow(n, start=.7, end=.1)", "heat.colors(n)",
72
                      "terrain.colors(n)", "topo.colors(n)",
72
                      "terrain.colors(n)", "topo.colors(n)",
73
                      "cm.colors(n)"))
73
                      "cm.colors(n)"))
74
{
74
{
75
    nt <- length(ch.col)
75
    nt <- length(ch.col)