Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

toRGB

Convert R colours to RGBA hexadecimal colour values


Description

Convert R colours to RGBA hexadecimal colour values

Usage

toRGB(x, alpha = 1)

Arguments

x

see the col argument in col2rgb for valid specifications

alpha

alpha channel on 0-1 scale

Value

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

See Also

Examples

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)

plotly

Create Interactive Web Graphics via 'plotly.js'

v4.10.0
MIT + file LICENSE
Authors
Carson Sievert [aut, cre] (<https://orcid.org/0000-0002-4958-2844>), Chris Parmer [aut], Toby Hocking [aut], Scott Chamberlain [aut], Karthik Ram [aut], Marianne Corvellec [aut] (<https://orcid.org/0000-0002-1994-3581>), Pedro Despouy [aut], Salim Brüggemann [ctb] (<https://orcid.org/0000-0002-5329-5987>), Plotly Technologies Inc. [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.