modify_pal modifies alpha transparency of the colors in the palette.

modify_pal(pal, alpha, show.pal = TRUE, title = "", ...)

Arguments

alpha

a single number or a vector of numbers between 0 and 1. These values define the degree of transparency of the colors in the palette. If alpha is a single number, the transparency of all the colors in the palette will be set to that value; if alpha is a vector of numbers, the transparency of the colors in the palette will be set to the corresponding alpha values. Also note that if the vector lengths of pal and alpha differ, extra elements in the longer vector will be omitted to match the length of the shorter one. See 'Details' section for more information on the concept of alpha transparency.

show.pal

logical. Whether to display the modified palette or not. Default to TRUE.

title

a character string giving the title of the displayed palette.

...

additional arguments passed to ggplot2::theme.

Value

A vector of hexadecimal color codes with two additional digits defining the degree of transparency.

Details

An alpha value defines the "transparency", or "opacity" of the color. A value of 0 means completely transparent (i.e., the background will completely “show through”); a value of 1 means completely opaque (i.e., none of the background will “show through”). In short, the lower the alpha value is, the lower "amount" of the color will be.

Examples

if (FALSE) { library(PalCreatoR) image_path <- system.file("Mountain.JPG", package = "PalCreatoR") My_pal <- create_pal(image = image_path, n = 5, resize = 0.1, method = "kmeans", colorblind = FALSE, sort = "value", show.pal = TRUE, title = "My Palette") My_new_pal <- modify_pal(pal = My_pal, alpha = c(0.2, 0.4, 0.6, 0.8, 1.0), show.pal = TRUE, title = "My New Palette") print(My_new_pal)}