col2hexStr | R Documentation |
Convert color to Hex string
col2hexStr(col, alpha = NULL, prefix = "#", ...)
col |
character or integer indicating color |
alpha |
|
prefix |
character, default is |
... |
passing to |
col2hexStr
converts colors such as 1, 2, 3, "red", "blue", ... into
hex strings that can be easily recognized by 'HTML', 'CSS' and 'JavaScript'.
Internally this function uses adjustcolor
with two differences:
the returned hex string does not contain alpha value if alpha
is NULL
;
the leading prefix "#" can be customized
characters containing the hex value of each color. See details
adjustcolor
col2hexStr(1, prefix = '0x') # "0x000000"
col2hexStr('blue') # "#0000FF"
# Change default palette, see "grDevices::colors()"
grDevices::palette(c('orange3', 'skyblue1'))
col2hexStr(1) # Instead of #000000, #CD8500
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.