Skip to content

Commit

Permalink
update doc for spec_tools
Browse files Browse the repository at this point in the history
  • Loading branch information
haozhu233 committed Jan 18, 2024
1 parent 472b631 commit 65788e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
15 changes: 13 additions & 2 deletions R/spec_tools.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#' Generate viridis or other color code for continuous values
#'
#' @inheritParams viridisLite::viridis
#' @param x continuous vectors of values
#' @param alpha The alpha transparency, a number in [0,1],
#' @param begin The (corrected) hue in [0,1] at which the color map begins.
#' @param end The (corrected) hue in [0,1] at which the color map ends.
#' @param direction Sets the order of colors in the scale. If 1, the default,
#' colors are ordered from darkest to lightest. If -1, the order of colors is
#' reversed.
#' @param option A character string indicating the color map option to use.
#' Eight options are available: "magma" (or "A"), "inferno" (or "B"),
#' "plasma" (or "C"), "viridis" (or "D"), "cividis" (or "E"),
#' "rocket" (or "F"), "mako" (or "G") and "turbo" (or "H").
#' @param na_color color code for NA values
#' @param scale_from input range (vector of length two). If not given,
#' is calculated from the range of x
Expand All @@ -12,7 +21,9 @@
spec_color <- function(x, alpha = 1, begin = 0, end = 1,
direction = 1, option = "D",
na_color = "#BBBBBB", scale_from = NULL,
palette = viridisLite::viridis(256, alpha, begin, end, direction, option)) {
palette = viridisLite::viridis(
256, alpha, begin, end, direction, option
)) {
n <- length(palette)
if (is.null(scale_from)) {
x <- round(rescale(x, c(1, n)))
Expand Down
21 changes: 6 additions & 15 deletions man/spec_color.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 65788e4

Please sign in to comment.