sl.colbar: Generate a Custom Colourbar

sl.colbarR Documentation

Generate a Custom Colourbar

Description

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

Usage

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(alpha) tuples (length-3 or length-4 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(alpha) 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

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 April 8, 2024, 8:34 a.m.