Convert a color name to a hex color code.

col_to_hex(col, alpha = 1)

Arguments

col

A character string corresponding to a supported color name (e.g., 'blue', 'darkred', etc.). See colors.

alpha

Degree of transparency from 0 (transparent) to 1 (opaque).

Examples

# Create scatter plot for bivariate normal
plot_blank(c(-4, 4), c(-4, 4))
# Draw semi-opaque blue points
points(rnorm(1000), rnorm(1000),
  pch = 19,
  col = col_to_hex("blue", alpha = .3)
)