Learn R Programming

ribiosPlot (version 1.3.0)

midCol: Blender two colors to get the midpoint color of two colors

Description

Blender two colors to get the midpoint color of two colors

Usage

midCol(col1, col2)

Value

The midpoint color of the two in the Lab space.

Arguments

col1

Character string, represting the first color. It can be of length 2 or 1; in the former case, col2 should be missing

col2

Character string, represting the second color

Examples

Run this code

midCol("black", "red")
midCol(c("black", "red"))
# \donttest{
set.seed(1778)
nCol <- 20
candCol <- grep("gr[a|e]y", colors(), value=TRUE, invert=TRUE)
firstCols <- sample(candCol, nCol)
secondCols <- rev(sample(candCol, nCol))
midCols <- sapply(seq(along=firstCols), function(i)
  midCol(firstCols[i], secondCols[i]))
plot.new()
plot.window(xaxt="n", yaxt="n", xlim=c(0, nCol),
     ylim=c(0.5, 4), bty="n")
title("Example of midCol")
segments(x0=1:nCol, y0=0, x1=1:nCol, y1=4, col="lightgray")
points(x=rep(1:nCol, each=3),
     y=rep(1:3, nCol),
     pch=21, cex=1.75,
     bg=as.vector(rbind(firstCols, midCols, secondCols)))
text(0, c(1.5, 2.5, 3.5), c("Second", "Midpoint", "First"),
     pos=4)
# }

Run the code above in your browser using DataLab