drawColorKey: Draw a color key in the current device

View source: R/misc.r

drawColorKeyR Documentation

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),
  labels = tick.marks,
  main = NULL,
  key.pos = c(0.925, 0.975, 0.05, 0.95),
  pos = 2,
  nlevels = length(tick.marks),
  color.palette = viridisLite::viridis(nlevels),
  tick.width = c(0.01, 0.0075),
  add.box = TRUE,
  na.col = NULL,
  na.height = 0.1,
  na.lab = "n/a",
  ...
)

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.

labels

Character vector. When provided, specifies using different labels for the tick marks than those provided by tick.marjks.

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.

na.col

Character scalar. If specified, adds an aditional box indicating the NA color.

na.height

Numeric scalar. Relative height of the NA box. Only use if na.col is not NULL.

na.lab

Character scalar. Label of the NA block. Only use if na.col is not NULL.

...

Further arguments to be passed to rect

Value

Invisible NULL.

Author(s)

George G. Vega Yon

See Also

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

Examples

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")

netdiffuseR documentation built on Aug. 30, 2023, 5:07 p.m.