values_to_colors_continuous.RdMap continuous values to diverging colors (dark red -> white -> dark green)
values_to_colors_continuous(
x,
labels = NULL,
min = -3,
max = 3,
neutral_min = -0.5,
neutral_max = 0.5,
low = "#7f0000",
mid = "#ffffff",
high = "#006400",
n = 201
)Numeric vector. Can be named or unnamed, but must align
with labels by name (preferred) or by position (same length).
Character vector of node labels (names to use in the result).
Minimum value that maps to the darkest red (values below are clipped).
Maximum value that maps to the darkest green (values above are clipped).
Color for low end (default dark red).
Color for midpoint (default white).
Color for high end (default dark green).
Number of discrete colors used internally for the gradient.
Named character vector of hex colors with names equal to labels.
z_values <- c(-2.5, -1, 0, 1, 2.5)
names(z_values) <- paste0("Node", 1:5)
colors <- values_to_colors_continuous(z_values)
print(colors)
#> Node1 Node2 Node3 Node4 Node5
#> "#983232" "#E4CACA" "#ffffff" "#CADFCA" "#328232"
t_values <- z_values * 10 + 50
names(t_values) <- paste0("Node", 1:5)
colors <- values_to_colors_continuous(t_values, min = 20, max = 80, neutral_min = 45, neutral_max = 55)
print(colors)
#> Node1 Node2 Node3 Node4 Node5
#> "#983232" "#E4CACA" "#ffffff" "#CADFCA" "#328232"