View source: R/standalone-update_alpha.R
| update_alpha | R Documentation |
update_alpha() modifies the transparency of colours and/or patterns.
update_alpha(fill, alpha)
fill |
A fill colour given as a |
alpha |
A transparency value between 0 (transparent) and 1 (opaque),
parallel to |
This is a fork of pattern utilities mainly added to {ggplot2} by Teun van den Brand.
update_alpha() does not depend on {ggplot2} or {scales}.
Like ggplot2::fill_alpha() but unlike scales::alpha() it also attempts
to set the transparency of <GridPattern> objects.
Unlike ggplot2::fill_alpha() it will work on a list of length one
containing a vector of color strings.
A character vector of colours or list of <GridPattern> objects.
To avoid taking a dependency on gridpattern you may copy the source of update_alpha()
into your own package under the permissive MIT license. Either use
usethis::use_standalone("trevorld/gridpattern", "standalone-update_alpha.R")
or copy the file update_alpha.R into your R directory and
add grDevices, grid, and rlang to the Imports of your DESCRIPTION file.
# Typical color input
update_alpha("red", 0.5)
# Pattern input
if (getRversion() >= "4.2" && requireNamespace("grid", quietly = TRUE)) {
update_alpha(list(grid::linearGradient()), 0.5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.