R Graphics: Grey Scales

Grey scales in R can be used effectively in data visualization.  Several simple functions can be used to great effect.

Creating Gray Scales

The gray.colors() function creates a vector of interpolated values that represent evenly-spaced gray colors. 

The function has the form gray.colors(num_colors, start = value, end = value, gamma = value).  End and start define the endpoints of the range of grays, with 0 = black and 1 = white being the extreme values. (By default, start = 0.3 and end = 0.9.) gamma is an optional argument which controls luminance.

Color Ramp Example


Gamma Correction

Gamma correction is required to correct for the properties of digital display terminals.  It also serves to better support human vision and the way light and color are perceived. The gray.colors() function has a default gamma = 2.2.


Back | Next