From a4a763b89dfcb0941c0ada986ff5d07f64eabdb1 Mon Sep 17 00:00:00 2001 From: Victoria Agudetse Roures Date: Tue, 10 Jan 2023 13:10:36 +0100 Subject: [PATCH] Add 'purpleorange' and 'orangepurple' color schemes --- R/clim.palette.R | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/R/clim.palette.R b/R/clim.palette.R index e847ad3..b23ff84 100644 --- a/R/clim.palette.R +++ b/R/clim.palette.R @@ -5,8 +5,9 @@ #' #'@param palette Which type of palette to generate: from blue through white #' to red ('bluered'), from red through white to blue ('redblue'), from -#' yellow through orange to red ('yellowred'), or from red through orange -#' to red ('redyellow'). +#' yellow through orange to red ('yellowred'), from red through orange to +#' red ('redyellow'), from purple through white to orange ('purpleorange'), +#' and from orange through white to purple ('orangepurple'). #'@param n Number of colors to generate. #' #'@examples @@ -29,9 +30,9 @@ clim.palette <- function(palette = "bluered") { attr(colorbar, 'na_color') <- 'pink' } else if (palette == "redblue") { colorbar <- colorRampPalette(c("#67001f", "#b2182b", "#d6604d", - "#f4a582", "#fddbc7", "#f7f7f7", - "#d1e5f0", "#92c5de", "#4393c3", - "#2166ac", "#053061")) + "#f4a582", "#fddbc7", "#f7f7f7", + "#d1e5f0", "#92c5de", "#4393c3", + "#2166ac", "#053061")) attr(colorbar, 'na_color') <- 'pink' } else if (palette == "yellowred") { colorbar <- colorRampPalette(c("#ffffcc", "#ffeda0", "#fed976", @@ -40,11 +41,24 @@ clim.palette <- function(palette = "bluered") { attr(colorbar, 'na_color') <- 'pink' } else if (palette == "redyellow") { colorbar <- colorRampPalette(rev(c("#ffffcc", "#ffeda0", "#fed976", - "#feb24c", "#fd8d3c", "#fc4e2a", - "#e31a1c", "#bd0026", "#800026"))) + "#feb24c", "#fd8d3c", "#fc4e2a", + "#e31a1c", "#bd0026", "#800026"))) + attr(colorbar, 'na_color') <- 'pink' + } else if (palette == "purpleorange") { + colorbar <- colorRampPalette(c("#2d004b", "#542789", "#8073ac", + "#b2abd2", "#d8daeb", "#f7f7f7", + "#fee0b6", "#fdb863", "#e08214", + "#b35806", "#7f3b08")) + attr(colorbar, 'na_color') <- 'pink' + } else if (palette == "orangepurple") { + colorbar <- colorRampPalette(rev(c("#2d004b", "#542789", "#8073ac", + "#b2abd2", "#d8daeb", "#f7f7f7", + "#fee0b6", "#fdb863", "#e08214", + "#b35806", "#7f3b08"))) attr(colorbar, 'na_color') <- 'pink' } else { - stop("Parameter 'palette' must be one of 'bluered', 'redblue', 'yellowred' or 'redyellow'.") + stop("Parameter 'palette' must be one of 'bluered', 'redblue', 'yellowred'", + "'redyellow', 'purpleorange' or 'orangepurple'.") } colorbar } -- GitLab