rgb {graphics} | R Documentation |
This function creates “colors” corresponding to the given
intensities (between 0 and max
) of the red, green and blue
primaries. The names argument may be used to provide names for the
colors.
The values returned by rgb
can be used with a
col=
specification in graphics functions or in par
.
rgb(red, green, blue, names=NULL, maxColorValue = 1)
red, blue, green |
vectors of same length with values in [0, M]
where M is maxColorValue . When this is 255 , the
red , blue and green values are coerced to
integers in 0:255 and the result is computed most efficiently. |
names |
character. The names for the resulting vector. |
maxColorValue |
number giving the maximum of the color values range, see above. |
col2rgb
the “inverse” for translating R colors
to RGB vectors;
rainbow
, hsv
, gray
.
rgb(0,1,0) (u01 <- seq(0,1, length=11)) stopifnot(rgb(u01,u01,u01) == gray(u01)) reds <- rgb((0:15)/15, g=0,b=0, names=paste("red",0:15,sep=".")) reds rgb(0, 0:12, 0, max = 255)# integer input