View source: R/col2transparent.R
col2transparent | R Documentation |
R color to transparent conversion.
col2transparent(col, alpha.perc = 0)
col |
R color name or R color pal [mandatory] |
alpha.perc |
an alpha-transparency level in percent [default: 0] |
A character vector with elements of 9 characters, "#" followed by the red, blue, green and alpha values in hexadecimal (after rescaling to 0 ... 255).
Kristian K Ullrich
palette
col2transparent("green", 50)
## Demonstrate the colors 1:8 in different palettes using a custom matplot()
sinplot <- function(main=NULL) {
x <- outer(
seq(-pi, pi, length.out = 50),
seq(0, pi, length.out = 9),
function(x, y) sin(x - y)
)
matplot(x, type = "l", lwd = 4, lty = 1, col = 1:9, ylab = "", main=main)
}
my.palette <- c(
"#CBC106", "#27993C", "#1C6838",
"#8EBCB5", "#389CA7", "#4D83AB",
"#CB7B26", "#BF565D", "#9E163C")
palette(my.palette); sinplot("my.palette")
## 25% transparent
palette(col2transparent(palette(my.palette), 25));
sinplot("my.palette - transparent")
## 50% transparent
palette(col2transparent(palette(my.palette), 50));
sinplot("my.palette - transparent")
## 75% transparent
palette(col2transparent(palette(my.palette), 75));
sinplot("my.palette - transparent")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.