Learn R Programming

EpiModel (version 0.95)

transco: Obtain Transparent Colors

Description

This function returns an RGB transparent color from an input R color

Usage

transco(col, alpha = 1, invisible = TRUE)

Arguments

col
vector of any of the three kinds of R color specifications (named, hexadecimal, or positive integer; see col2rgb)
alpha
transparency level, where 0 is transparent and 1 is opaque
invisible
supresses printing of the RGB color

Value

  • A vector of length equal to the input col vector, containing the transformed color values in hexidemical format.

Details

The purpose of this function is to facilitate color transparency, which is used widely in EpiModel plots. This is an internal function that is not ordinarily called by the end-user.

See Also

rgb, col2rgb

Examples

Run this code
# Three-variable bubble plot to show transparency
n <- 25
x <- sort(sample(1:200, n))
y <- 10 + 2*x + rnorm(n, 0, 10)
z <- rpois(n, 10)

# Input named R color and transparency level
tcol <- transco("steelblue", 0.5)

plot(x,y, cex=z/4, pch=21, col="black", bg=tcol, lwd=1.2, axes=FALSE,
     ylim=c(0,500), xlim=c(0,250), yaxs="r", xaxs="r")
axis(2, seq(0,500,100), col="white", las=2, cex.axis=0.9, mgp=c(2,0.5,0))
axis(1, seq(0,250,50), cex.axis=0.9, mgp=c(2,0.5,0))
abline(h=seq(100,500,100), col=transco("black", 0.35))

Run the code above in your browser using DataLab