BlendColors | R Documentation |
Mix two colors in RGB space
BlendColors(x, y, gamma)
x |
vector of R colors. |
y |
vector of R colors. |
gamma |
numeric vector with values in [0 ; 1] specifying the proportion of |
BlendColors
returns a vector of R colors.
n <- 50
x <- 0:(n^2 - 1) / (n^2 - 1)
y <- rep(0:(n - 1) / (n - 1), length.out = length(x))
cm1 <- DefineColorMap(thresholds = 0:2/2, colors = c("blue", "yellow", "red"))
cm2 <- DefineColorMap(thresholds = 0:2/2, colors = grey(c(1, 0, 1)))
c1 <- MakeColors(x, cm1)
c2 <- MakeColors(x, cm2)
clr <- BlendColors(c1, c2, gamma = y)
plot(x, y, col = clr, pch = 20, cex = 2)
cm1 <- AutoColorParameters("Wry")
cm2 <- AutoColorParameters("WBW")
c1 <- MakeColors(x, cm1)
c2 <- MakeColors(x, cm2)
clr <- BlendColors(c1, c2, gamma = y)
plot(x, y, col = clr, pch = 20, cex = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.