Learn R Programming

rasterImage (version 0.4.0)

colorPalette: Defines a color palette

Description

This function defines a color palette and returns a vector of colors. The palettes itself are adapted from the ColorBrewer project.

Usage

colorPalette(n = NULL, type = "spectral", inv = F)

Arguments

n

number of colors to produce

type

sets the type of color palette. See Details

inv

revert the order of colors

Value

returns a vector of colors to be passed to image or rasterImage

Details

The parameter type controls the output palette type as follows:

"spectral"

spectral colors from blue to red

"specrtalHalf"

spectral colors from green to red

"green"

MultiHue yellow - green

"blue"

MultiHue yellow - green blue

"orange"

MultiHue yellow - orange - brown

"red"

MultiHue yellow - orange red

"red-white-bule","bwr"

red - white - blue colors

"rainbow"

reproduces the rainbow color set

"black-white","bw"

gray scale colors

"white-black","wb"

gray scale colors from white to black

"jet.colors","jc"

dark blue to dark red

"hzdr1"

HZDR cooperate design colors

"hzdr2"

HZDR cooperate design colors

If a vector of color names is supported, then a customized palette will be calculated according to these colors.

References

http://colorbrewer2.org by Cynthia A. Brewer, Geography, Pennsylvania State University

Examples

Run this code
# NOT RUN {
# default "spectral" palette
barplot(rep(1,10), col = colorPalette(10))

# custom color palette
barplot(rep(1,10), col = colorPalette(n = 10, type = c("red","blue","yellow")))
# }

Run the code above in your browser using DataLab