Learn R Programming

prevR (version 2.2)

prevR.colors: Continuous color palettes.

Description

Functions generating color palettes useable with Rgraphical functions, in particular with spplot. These palettes are continuous, contrast being accentuated by darkening and lightening extrem values. prevR.demo.pal plot the available palettes. prevR.colors.qgis.pal export a palette in a text file readable by Quantum GIS, an open-source mapping software.

Usage

prevR.demo.pal(n, border, main, ch.col)
prevR.colors.red(n)
prevR.colors.red.inverse(n)
prevR.colors.blue(n)
prevR.colors.blue.inverse(n)
prevR.colors.green(n)
prevR.colors.green.inverse(n)
prevR.colors.gray(n)
prevR.colors.gray.inverse(n)
prevR.colors.qgis.pal(file, at, pal="red", inverse=FALSE)

Arguments

n
number of different colors in the palette.
border
border color.
main
title.
ch.col
list of palettes to show.
file
file name with extension.
at
list of values of the palette.
pal
color palette to use ("red", "green", "blue" or "gray").
inverse
use the inverse palette?

Value

  • prevR.demo.pal plot the color palettes. prevR.colors.qgis.pal export a color palette in a texte file readable by Quantum GIS. The other functions return a list of colors coded in hexadecimal.

encoding

utf8

Details

prevR.colors.red produces a color gradation from white/yellow to red/dark red. prevR.colors.blue produces a color gradation from light blue to dark blue. prevR.colors.green produces a color gradation from light green to dark green. prevR.colors.gray produces a color gradation from white/light gray to dark gray/black. Functions with a suffix .inverse produce the same color gradation, but from dark colors to light ones.

See Also

Other color palettes are available in R. See for example rainbow{grDevices} or the package RColorBrewer.

Examples

Run this code
prevR.demo.pal(25)
prevR.colors.red(5)
col2rgb(prevR.colors.red(5))

prevR.colors.qgis.pal('palette.txt', seq(0,25,length.out=100), 'red')

Run the code above in your browser using DataLab