sl.colbar: Generate a Custom Colourbar

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/sl.colbar.R

Description

Generate a colourbar of length N from a series of >= 2 colours with linear interpolation in RGB-space between the colours. The provided colours can be placed not only in equidistant steps (default), but also in non-equidistant steps.

Usage

1
sl.colbar(cols, N = (length(cols) - 1) * 10 + 1, cols.at = seq(0, 1, by = 1/(length(cols) - 1)))

Arguments

cols

either a list of (at least 2) RGB tuples (length-3 vectors in the range [0,1]) or a character vector of named colours and/or hexadecimal-coded RGB colours. Defines the basis colours of the colourbar.

N

number of colours the resulting colourbar shall contain.

cols.at

a vector of length N that specifies at which relative locations the basis colours are placed. The first and last elements should be 0 and 1, and the remaining should have values inbetween in ascending order. By default, the basis colours are placed in equidistant steps.

Details

Can also use RColorBrewer colourbars as input, see corresponding examples below.

Value

A list of length N with characters describing RGB values (hexadecimal) of the colours comprising the colourbar.

Author(s)

Helge Goessling

See Also

sl.view.colbar, sl.plot.colbar, sl.num2colbar, sl.num2colbarbreaks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
sl.colbar(cols=list(c(1,0,0),c(1,1,1),c(0,0,1)),N=5)
## Should return:
## [[1]]
## [1] "#FF0000"
## 
## [[2]]
## [1] "#FF8080"
## 
## [[3]]
## [1] "#FFFFFF"
## 
## [[4]]
## [1] "#8080FF"
## 
## [[5]]
## [1] "#0000FF"

require("RColorBrewer")
## For a list of all available Color Brew colourbars, type display.brewer.all()
sl.colbar(cols=brewer.pal(5,"BrBG"),N=5)
## Should return:
## [[1]]
## [1] "#A6611A"
## 
## [[2]]
## [1] "#DFC27D"
## 
## [[3]]
## [1] "#F5F5F5"
## 
## [[4]]
## [1] "#80CDC1"
## 
## [[5]]
## [1] "#018571"

## Using a different 'N' (as by default), colours are interpolated inbetween, e.g.:
sl.view.colbar(sl.colbar(cols=brewer.pal(11,"BrBG")))

helgegoessling/spheRlab documentation built on Sept. 29, 2017, 6:36 a.m.