netdiffuseR (version 1.17.0)

drawColorKey: Draw a color key in the current device

Description

Draw a color key in the current device

Usage

drawColorKey(x, tick.marks = pretty_within(x), main = NULL, key.pos = c(0.925, 0.975, 0.05, 0.95), pos = 2, nlevels = length(tick.marks), color.palette = (grDevices::colorRampPalette(c("lightblue", "yellow", "red")))(nlevels), tick.width = c(0.01, 0.0075), add.box = TRUE, ...)

Arguments

x
A numeric vector with the data (it is used to extract the range).
tick.marks
A numeric vector indicating the levels to be included in the axis.
main
Character scalar. Title of the key.
key.pos
A numeric vector of length 4 with relative coordinates of the key (as % of the plotting area, see par("usr"))
pos
Integer scalar. Position of the axis as in text.
nlevels
Integer scalar. Number of levels (colors) to include in the color key.
color.palette
Color palette of length(nlevels).
tick.width
Numeric vector of length 2 indicating the length of the inner and outer tick marks as percentage of the axis.
add.box
Logical scalar. When TRUE adds a box around the key.
...
Further arguments to be passed to rect

Value

Invisible NULL.

See Also

Other visualizations: dgr, diffusionMap, grid_distribution, hazard_rate, plot_adopters, plot_diffnet2, plot_diffnet, plot_infectsuscep, plot_threshold, rescale_vertex_igraph

Examples

Run this code
set.seed(166)
x <- rnorm(100)
col <- colorRamp(c("lightblue", "yellow", "red"))((x - min(x))/(max(x) - min(x)))
col <- rgb(col, maxColorValue = 255)
plot(x, col=col, pch=19)
drawColorKey(x, nlevels = 100, border="transparent",
 main="Key\nLike A\nBoss")

Run the code above in your browser using DataLab