trans.color | R Documentation |
Make transparent colors.
trans.color(colors, alpha = 0.3, mix = "white", ratio = 0.7)
colors |
a character vector representing base colors. |
alpha |
a numeric value between 0 to 1 representing transparency. |
mix |
a character literal of color represent a color. The base colors are mixed with this color. |
ratio |
a numeric value between 0 to 1 representing mixture ratio of the base colors and mix color. |
a character vector of transparent colors.
#---------------------------------------------------------------------------
# Example 1: change alpha.
#---------------------------------------------------------------------------
col1 <- "red"
col2 <- trans.color(col1, alpha = 0.1, mix = "white", ratio = 0.7)
col3 <- trans.color(col1, alpha = 0.5, mix = "white", ratio = 0.7)
col4 <- trans.color(col1, alpha = 0.8, mix = "white", ratio = 0.7)
barplot(1:4, col = c(col1, col2, col3, col4))
#---------------------------------------------------------------------------
# Example 2: mix with black.
#---------------------------------------------------------------------------
col1 <- "red"
col2 <- trans.color(col1, alpha = 0.1, mix = "black", ratio = 0.7)
col3 <- trans.color(col1, alpha = 0.5, mix = "black", ratio = 0.7)
col4 <- trans.color(col1, alpha = 0.8, mix = "black", ratio = 0.7)
barplot(1:4, col = c(col1, col2, col3, col4))
#---------------------------------------------------------------------------
# Example 3: change ratio.
#---------------------------------------------------------------------------
col1 <- "red"
col2 <- trans.color(col1, alpha = 0.3, mix = "white", ratio = 0.1)
col3 <- trans.color(col1, alpha = 0.3, mix = "white", ratio = 0.4)
col4 <- trans.color(col1, alpha = 0.3, mix = "white", ratio = 0.9)
barplot(1:4, col = c(col1, col2, col3, col4))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.