colors {mining} | R Documentation |
Compute a color scheme with a specified number of levels.
default.colors(n) default.colors.w(n) YR.colors(n) YlGnBu.colors(n) OrRd.colors(n) gray.colors(n) RYB.colors(n) BrBg.colors(n) RC.colors(n) GM.colors(n)
n |
the number of colors desired |
The first two schemes are categorical, providing maximum
separation in hue, intended for depicting unordered categories.
default.colors
has only dark colors, good for coloring points,
while default.colors.w
includes light colors, good for filling
regions.
The next four schemes are sequential, from light to dark,
with variation in hue to increase discrimination.
They are intended for depicting ordered levels.
The sequential order is more easily perceived with these schemes than
with the built-in palettes heat.colors
,
terrain.colors
,
and topo.colors
.
The ordering can also be seen by the color-blind and when printed in black
and white.
The main difference between the sequential schemes is the variation in
hue, with YR.colors
having the most variation and
gray.colors
having the least.
Generally you should choose the amount of variation according to the
number of levels.
I recommend OrRd.colors
for three levels, YlGnBu.colors
for four to eight levels, and YR.colors
beyond eight levels.
The last four schemes are double-ended or diverging
schemes,
which progress from one hue to a second hue, passing through white
in the middle. They are intended for representing signed ordered
levels, such as residuals. The main difference between them is the
amount of separation between colors, so generally you use
GM.colors
when you want a few levels and
RYB.colors
when you want many.
These functions can be used as the color.palette
parameter to
filled.contour
and color.plot
, for example.
A vector of strings, naming colors.
Tom Minka
The schemes in
YlGnBu.colors
, OrRd.colors
, RYB.colors
, and
BrBg.colors
are from ColorBrewer.
The scheme in YR.colors
is from Howard Seltman.
Mark A. Harrower and Cynthia A. Brewer. ColorBrewer: An Online Tool for Selecting Color Schemes for Maps, The Cartographic Journal, in press. http://www.colorbrewer.org/, http://www.personal.psu.edu/faculty/c/a/cab38/ColorBrewerBeta.html
Generalized color schemes for Mapping and Visualization. From Cynthia Brewer, Color Use Guidelines for Mapping and Visualization. Reprinted at the Gallery of Data Visualization by Michael Friendly. http://www.math.yorku.ca/SCS/Gallery/images/S12-fullstructureClean.gif
Dan Carr. Color perception, the importance of gray and residuals, on a choropleth map. Statistical Computing & Graphics Newsletter 5(1):16-20, 1994 http://cm.bell-labs.com/cm/ms/who/cocteau/newsletter/issues/back/v51.pdf
data(Housing) color.plot(Price ~ Rooms + Low.Status, Housing, bg=gray(0.5), color.palette=YlGnBu.colors) color.plot(Price ~ Rooms + Low.Status, Housing, bg=gray(0.5), color.palette=YR.colors) color.plot(Price ~ Rooms + Low.Status, Housing, bg=gray(0.5), color.palette=RYB.colors,nlevels=5) # also see examples for color.cone