Description Usage Arguments Details Author(s) References See Also Examples
This function produces a color bar.
1 2 |
colpalette |
a color palette supplied by the user; defaults to the red-white-blue palette if left undefined |
min |
the smallest numeric value corresponding to the color on the extreme left of the color palette |
max |
the largest numeric value corresponding to the color on the extreme right of the color palette |
nticks |
number of tick lines on the color bar |
ticks |
spacing for the tick marks on the color bar |
tit |
title for the color bar |
This R code is a based on John Colby's (2011) color.bar
code. A user-defined color palette can be generated using the
colorRampPalette
function. See www.colorbrewer2.org for interesting color palette options.
Tsung Fei Khang tfkhang@um.edu.my
Colby J. (2011). Color bar legends for neuroimaging in R. Available at http://www.colbyimaging.com/wiki/statistics/color-bars.
Khang TF, Soo OYM, Tan WB, Lim LHS. (2016). Monogenean anchor morphometry: systematic value, phylogenetic signal, and evolution. PeerJ 4:e1668.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #define a color scale
tones <- c("#99000D", "#FB6A4A", "white", "#6BAED6", "#084594")
multihue <- colorRampPalette(tones, space = "Lab")(101)
#create a two-panel figure with width ratio of 4:1
nf <- layout(matrix(c(1,1,1,1,2),2,5,byrow=TRUE))
layout.show(nf)
#mapping a matrix of randomly chosen numbers between -1 and 1 to
#colors in the color scale
h <- matrix(runif(100, -1, 1),10,10)
image(h,col=multihue,xaxt="n", yaxt="n")
#add color bar
par(mar=c(5,5,5,2))
colorBar(colpalette=multihue, min=-1,max=1)
|
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Warning messages:
1: In rgl.init(initValue, onlyNULL) : RGL: unable to open X11 display
2: 'rgl_init' failed, running with rgl.useNULL = TRUE
3: .onUnload failed in unloadNamespace() for 'rgl', details:
call: fun(...)
error: object 'rgl_quit' not found
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.