Function to setup alpha value for a set of colours

Share:

Description

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

Usage

1
set_alpha(col, alpha)

Arguments

col

a vector of colours

alpha

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

See Also

fDColorPalette

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()
par( mfrow = c( 1, 2 ) )

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

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

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.