setAlpha: A progress bar function to run within a 'for' loop

Description Usage Arguments Examples

View source: R/setAlpha.R

Description

A function to change the alpha value (transparency) of colours that are defined as strings.

Usage

1
setAlpha(colours, alphas)

Arguments

colours

A vector of colours defined by strings of characters

alphas

The transparency (0=transparent, 1=opaque)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Define the coordinates of three points
x <- c(0.2, 0.5, 0.8)
y <- c(0.5, 0.5, 0.5)

# Define the colours for the points
colours <- c("green", "blue", "red")

# Plot the points - set the transparency
plot(x, y, bty="n", xlab="X", ylab="Y", las=1, pch=19, cex=30, xlim=c(0,1), ylim=c(0,1),
     col=setAlpha(colours, alpha=0.5))

JosephCrispell/plotteR documentation built on June 6, 2021, 7:24 p.m.