sl.num2colbar | R Documentation |
Convert a numerical vector or array to integers corresponding to discrete intervals defined by colourbar breaks. If the latter are not provided (as argument breaks
or as an element of colbar
named 'breaks'), they are computed by calling sl.num2colbarbreaks
). This function is used by various plotting functions.
sl.num2colbar(num, colbar = NULL, breaks = NA, breaks.log = FALSE)
num |
a numerical scalar, vector, or array that shall be mapped to colourbar breaks |
colbar |
a spheRlab colourbar of length |
breaks |
a vector of length |
breaks.log |
a logical value indicating whether the breaks shall be placed in logarithmic steps. Default is |
This function is used by sl.num2colbarbreaks
, sl.plot.elem
, sl.plot.field
, and sl.plot.fld.curvilin
.
colour.index |
A vector or array with the same dimensions as the argument |
breaks |
A vector giving the |
Helge Goessling
sl.colbar
, sl.num2colbarbreaks
.
cb = sl.colbar(cols=list(c(1,0,0),c(.5,.5,.5),c(0,0,1)),N=5)
num = runif(n=100,min=-5,max=5)
cb_breaks = sl.num2colbarbreaks(num=num,colbar=cb)
sl.num2colbar(num=num,colbar=cb)
## Should return something like (result subject to randomness)
## $colour.index
## [1] 1 5 4 4 1 2 2 2 2 3 1 2 4 5 2 1 1 4 2 1 1 2 4 4 3 4 2 3 5 1 3 4 5 2 5 5 1 2 2
## [40] 5 1 2 3 4 3 1 4 4 2 1 5 1 5 4 2 1 2 2 3 3 2 4 4 4 2 2 3 1 1 4 4 3 2 1 5 2 3 1
## [79] 2 3 1 5 2 3 3 4 4 4 5 3 2 3 4 2 3 5 2 4 3 1
##
## $breaks
## [1] -2.9800799 -0.9964841 0.9871118 2.9707076
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.