Learn R Programming

plotly (version 4.10.3)

toRGB: Convert R colours to RGBA hexadecimal colour values

Description

Convert R colours to RGBA hexadecimal colour values

Usage

toRGB(x, alpha = 1)

Value

hexadecimal colour value (if is.na(x), return "transparent" for compatibility with Plotly)

Arguments

x

see the col argument in col2rgb for valid specifications

alpha

alpha channel on 0-1 scale

See Also

showRGB()

Examples

Run this code

toRGB("steelblue") 
# [1] "rgba(70,130,180,1)"

m <- list(
  color = toRGB("red"),
  line = list(
    color = toRGB("black"), 
    width = 19
  )
)

plot_ly(x = 1, y = 1, marker = m)

Run the code above in your browser using DataLab