Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trans.colors

Make Colors Transparent


Description

Takes a vector of colors (as color names or rgb hex values) and adds a specified alpha transparency to each.

Usage

trans.colors(col, alpha = 0.5, names = NULL)

Arguments

col

A character vector of colors, either as color names or rgb hex values

alpha

alpha transparency value(s) to apply to each color (0 means fully transparent and 1 means opaque)

names

optional character vector of names for the colors

Details

Colors (col) and alpha need not be of the same length. The shorter one is replicated to make them of the same length.

Value

A vector of color values of the form "#rrggbbaa"

Author(s)

Michael Friendly

See Also

Examples

trans.colors(palette(), alpha=0.5)

# alpha can be vectorized
trans.colors(palette(), alpha=seq(0, 1, length=length(palette())))

# lengths need not match: shorter one is repeated as necessary
trans.colors(palette(), alpha=c(.1, .2))

trans.colors(colors()[1:20])

# single color, with various alphas
trans.colors("red", alpha=seq(0,1, length=5))
# assign names
trans.colors("red", alpha=seq(0,1, length=5), names=paste("red", 1:5, sep=""))

heplots

Visualizing Hypothesis Tests in Multivariate Linear Models

v1.3-8
GPL (>= 2)
Authors
John Fox [aut], Michael Friendly [aut, cre], Georges Monette [ctb], Phil Chalmers [ctb]
Initial release
2021-01-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.