set_alpha manipulates a vector of color representations in order to setup the alpha value, and get the desired transparency level.

set_alpha(col, alpha)

Arguments

col

a vector of colors

alpha

the value(s) of alpha for (each of) the colors.

See also

Examples


original_col = c( 'blue', 'red', 'green', 'yellow' )

alpha_col = set_alpha( original_col, 0.5 )

alpha_col = set_alpha( original_col, c(0.5, 0.5, 0.2, 0.1 ) )

dev.new()
oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, 2))

plot( seq_along( original_col ),
      seq_along( original_col ),
      col = original_col,
      pch = 16,
      cex = 2,
      main = 'Original colors' )

plot( seq_along( alpha_col ),
      seq_along( alpha_col ),
      col = alpha_col,
      pch = 16,
      cex = 2,
      main = 'Alpha colors' )

par(oldpar)