Add a fallback palette based on Viridis
This commit is contained in:
parent
133a4b29b0
commit
a8ff478e21
1 changed files with 19 additions and 0 deletions
19
R/pal_fallback.R
Normal file
19
R/pal_fallback.R
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
pal_fallback <- function(reverse = FALSE,
|
||||||
|
color_ramp_palette = FALSE,
|
||||||
|
discrete = FALSE,
|
||||||
|
n = 5,
|
||||||
|
...){
|
||||||
|
|
||||||
|
pal <- if(discrete) { viridisLite::viridis(n) } else {viridisLite::magma(n)}
|
||||||
|
|
||||||
|
if (reverse) pal <- rev(pal)
|
||||||
|
|
||||||
|
if (color_ramp_palette) {
|
||||||
|
rlang::check_installed("grDevices", reason = "Package \"grDevices\" needed for `pal_fallback()` with 'color_ramp_palette' set to `TRUE` to work. Please install it.")
|
||||||
|
|
||||||
|
pal <- grDevices::colorRampPalette(pal, ...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return(pal)
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue