sl.colbar | R Documentation |
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.
sl.colbar(cols, N = (length(cols) - 1) * 10 + 1, cols.at = seq(0, 1, by = 1/(length(cols) - 1)))
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 |
Can also use RColorBrewer colourbars as input, see corresponding examples below.
A list of length N
with characters describing RGB(alpha) values (hexadecimal) of the colours comprising the colourbar.
Helge Goessling
sl.view.colbar
, sl.plot.colbar
, sl.num2colbar
, sl.num2colbarbreaks
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")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.