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 on the 'pdf', 'windows',
     'quartz' and 'X11(type="cairo")' devices and associated bitmap
     devices ('jpeg', 'png', 'bmp', 'tiff' and 'bitmap'). They are
     supported by several third-party devices such as those in packages
     'Cairo', 'cairoDevice' and 'JavaGD'.  Only some of these devices
     support semi-transparent backgrounds.

     Most other graphics devices plot semi-transparent colors as fully
     transparent, usually with a warning when first encountered.

_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)

     rgb((0:15)/15, green=0, blue=0, names=paste("red",0:15,sep="."))

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

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

