makeColorMatrix: Create a matrix of increasingly transparent colors

View source: R/np_utility.R

makeColorMatrixR Documentation

Create a matrix of increasingly transparent colors

Description

makeColorMatrix is a convenience function for plotting with transparent colors.

Usage

makeColorMatrix()

Details

This function take no arguments, but generates rows corresponding to red, blue, green, gray, purple and gold with increasing transparency moving from left to right across the columns.

Value

A 6 x 5 matrix of colors.

See Also

rainbow, col2rgb, rgb.

Examples

plot(1,1,col="white",xlim=c(0,10),ylim=c(0,10))
for(n in 1:6){rect(0:4,rep(8-n,5),1:5,rep(9-n,5),col=as.matrix(makeColorMatrix())[n,])}

#An example how it can be used in practice:
myData<-rnorm(600)
fact<-factor(c(rep("a",100),rep("b",100),rep("c",100),rep("d",100),rep("e",100),rep("f",100)))
plot(myData,col=makeColorMatrix()[fact,3])

ZachHunter/NicePlots.R documentation built on Sept. 23, 2023, 4:04 a.m.