rgb                package:grDevices                R Documentation

_R_G_B _C_o_l_o_r _S_p_e_c_i_f_i_c_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     This function creates colors corresponding to the given
     intensities (between 0 and 'max') of the red, green and blue
     primaries.

     An alpha transparency value can also be specified (0 means fully
     transparent and 'max' means opaque). If 'alpha' is not specified,
     an opaque colour is generated.

     The names argument may be used to provide names for the colors.

     The values returned by these functions can be used with a 'col='
     specification in graphics functions or in 'par'.

_U_s_a_g_e:

     rgb(red, green, blue, alpha, names = NULL, maxColorValue = 1)

_A_r_g_u_m_e_n_t_s:

red, blue, green, alpha: numeric vectors with values in [0, M] where M
          is 'maxColorValue'.  When this is '255', the 'red', 'blue',
          'green', and 'alpha' 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.

_D_e_t_a_i_l_s:

     The colors may be specified by passing a matrix or dataframe as
     argument 'red', and leaving 'blue' and 'green' missing. In this
     case the first three columns of 'red' are taken to be the 'red',
     'green' and 'blue' values.

     Semi-transparent colors ('0 < alpha < 1') are supported only on
     some devices: at the time of writing only on the 'pdf', 'windows'
     and 'quartz' devices as well as several third-party devices such
     as those in packages 'Cairo', 'cairoDevice', 'JavaGD' and
     'RSvgDevice'.  On most of these devices the actual alpha values
     used are multiples of 1/255.

     Typically other graphics devices silently plot semi-transparent
     colors as fully transparent.

_V_a_l_u_e:

     A character vector with elements of 7 or 9 characters, '"#"'
     followed by the red, blue, green and optionally alpha values in
     hexadecimal (after rescaling to '0 ... 255').

_S_e_e _A_l_s_o:

     'col2rgb'for translating R colors to RGB vectors; 'rainbow',
     'hsv', 'hcl', 'gray'.

_E_x_a_m_p_l_e_s:

     rgb(0,1,0)
     (u01 <- seq(0,1, length=11))
     stopifnot(rgb(u01,u01,u01) == gray(u01))
     reds <- rgb((0:15)/15, green=0, blue=0, names=paste("red",0:15,sep="."))
     reds

     rgb(0, 0:12, 0, max = 255)# integer input

     ramp <- colorRamp(c("red", "white"))
     rgb( ramp(seq(0, 1, length = 5)), max = 255)

