From 88c117a6b1d94859ec841be2a7f70144d76072bb Mon Sep 17 00:00:00 2001 From: Mattias Date: Sat, 7 May 2022 20:38:46 +0100 Subject: [PATCH] Added options for ggplot2.ordinal.{fill,colour} This should make ggplot respect the current ggthemr theme palette / swatch and not default to viridis. --- R/ggthemr.R | 9 ++++++++- R/ggthemr_reset.R | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/R/ggthemr.R b/R/ggthemr.R index 98773f6..1f04fef 100644 --- a/R/ggthemr.R +++ b/R/ggthemr.R @@ -53,8 +53,15 @@ ggthemr <- function(palette = 'dust', colours <- palette$swatch[-1] options('ggplot2.discrete.fill' = function(...) discrete_scale('fill', 'ggthemr', discrete_colours(colours), ...)) options('ggplot2.discrete.colour' = function(...) discrete_scale('colour', 'ggthemr', discrete_colours(colours), ...)) + + options('ggplot2.ordinal.fill' = function(...) discrete_scale('fill', 'ggthemr', discrete_colours(colours), ...)) + options('ggplot2.ordinal.colour' = function(...) discrete_scale('colour', 'ggthemr', discrete_colours(colours), ...)) + + + options('ggplot2.continuous.fill' = function(...) continuous_scale('fill', 'ggthemr', - seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']], 'Lab'), + +seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']], 'Lab'), guide = 'colourbar', ...)) options('ggplot2.continuous.colour' = function(...) continuous_scale('colour', 'ggthemr', seq_gradient_pal(palette$gradient[['low']], palette$gradient[['high']], 'Lab'), diff --git a/R/ggthemr_reset.R b/R/ggthemr_reset.R index 0e41389..6eea5ec 100644 --- a/R/ggthemr_reset.R +++ b/R/ggthemr_reset.R @@ -11,6 +11,8 @@ ggthemr_reset <- function () { options('ggplot2.discrete.color' = NULL) options('ggplot2.continuous.fill' = NULL) options('ggplot2.continuous.color' = NULL) + options('ggplot2.ordinal.colour' = NULL) + options('ggplot2.ordinal.fill' = NULL) # resetting geoms current_theme_info <- get_themr()