set_alpha: Function to setup alpha value for a set of colors

Description Usage Arguments See Also Examples

View source: R/utils.R

Description

set_alpha manipulates a vector of color 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 colors

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
23
24
25
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)

roahd documentation built on Aug. 24, 2020, 9:07 a.m.