setAlpha: add alpha transparency to a named color

View source: R/np_utility.R

setAlphaR Documentation

add alpha transparency to a named color

Description

Takes a named color such as "red" or "darkgreen" and adds a level of transparency based on the alpha setting.

Usage

setAlpha(x, alpha = 0.2)

Arguments

x

character string; a text string corresponding to an R color

alpha

numeric [0-1]; sets the level of transparency.

Details

setAlpha is a convenience function that uses the col2rgb and rgb to add transparancy to named colors.

Value

An rbg color with transparancy alpha.

See Also

makeColorMatrix, rainbow, col2rgb, rgb.

Examples

plot(1,1,col="white",xlim=c(0,10),ylim=c(0,10))
rect(1,1,7,7,col=setAlpha("darkblue"))
rect(3,3,9,9, col=setAlpha("red"))


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