Mercurial > repos > marie-tremblay-metatoul > 2dnmrannotation
diff viridis.R @ 3:546c7ccd2ed4 draft default tip
"planemo upload for repository https://github.com/workflow4metabolomics/tools-metabolomics commit 911f4beba3dcb25c1033e8239426f8f763683523"
author | workflow4metabolomics |
---|---|
date | Fri, 04 Feb 2022 09:01:11 +0000 |
parents | dff7bde22102 |
children |
line wrap: on
line diff
--- a/viridis.R Tue Feb 04 10:59:26 2020 -0500 +++ b/viridis.R Fri Feb 04 09:01:11 2022 +0000 @@ -1,5 +1,4 @@ -viridis <- function (n, alpha = 1, begin = 0, end = 1, direction = 1, option = "D") -{ +viridis <- function(n, alpha = 1, begin = 0, end = 1, direction = 1, option = "D") { if (begin < 0 | begin > 1 | end < 0 | end > 1) { stop("begin and end must be in [0,1]") } @@ -11,18 +10,17 @@ begin <- end end <- tmp } - option <- switch(EXPR = option, A = "A", magma = "A", - B = "B", inferno = "B", C = "C", plasma = "C", - D = "D", viridis = "D", E = "E", cividis = "E", - { + option <- switch(EXPR = option, A = "A", magma = "A", + B = "B", inferno = "B", C = "C", plasma = "C", + D = "D", viridis = "D", E = "E", cividis = "E", { warning(paste0("Option '", option, "' does not exist. Defaulting to 'viridis'.")) "D" }) - map <- viridisLite::viridis.map[viridisLite::viridis.map$opt == + map <- viridisLite::viridis.map[viridisLite::viridis.map$opt == option, ] map_cols <- grDevices::rgb(map$R, map$G, map$B) - fn_cols <- grDevices::colorRamp(map_cols, space = "Lab", + fn_cols <- grDevices::colorRamp(map_cols, space = "Lab", interpolate = "spline") - cols <- fn_cols(seq(begin, end, length.out = n))/255 + cols <- fn_cols(seq(begin, end, length.out = n)) / 255 grDevices::rgb(cols[, 1], cols[, 2], cols[, 3], alpha = alpha) -} \ No newline at end of file +}