From 8031a33029836a62b3bdb803a93bc1d8a70b3c73 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Wed, 5 Jun 2024 09:19:37 +0200 Subject: [PATCH 1/4] rescue old palettes --- R/scale-discrete-.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/scale-discrete-.R b/R/scale-discrete-.R index b957b97b97..4d3d3354fc 100644 --- a/R/scale-discrete-.R +++ b/R/scale-discrete-.R @@ -140,6 +140,10 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete, map = function(self, x, limits = self$get_limits()) { if (is.discrete(x)) { + # Guard against old use of having identity palettes + if (identical(.subset2(self, "palette"), identity)) { + self$palette <- seq_len + } values <- self$palette(length(limits)) if (!is.numeric(values)) { cli::cli_abort( From 34f8a27aa5317e96c93c6d549a04f47edefc62ec Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Mon, 8 Jul 2024 10:23:35 +0200 Subject: [PATCH 2/4] Revert "rescue old palettes" This reverts commit 8031a33029836a62b3bdb803a93bc1d8a70b3c73. --- R/scale-discrete-.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/R/scale-discrete-.R b/R/scale-discrete-.R index 4d3d3354fc..b957b97b97 100644 --- a/R/scale-discrete-.R +++ b/R/scale-discrete-.R @@ -140,10 +140,6 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete, map = function(self, x, limits = self$get_limits()) { if (is.discrete(x)) { - # Guard against old use of having identity palettes - if (identical(.subset2(self, "palette"), identity)) { - self$palette <- seq_len - } values <- self$palette(length(limits)) if (!is.numeric(values)) { cli::cli_abort( From 098ab30eae2f7acf5faba977c4bb15aa538266ce Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Mon, 8 Jul 2024 10:33:42 +0200 Subject: [PATCH 3/4] rescue in construction --- R/scale-.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/scale-.R b/R/scale-.R index 9eaa153590..17f028c4ed 100644 --- a/R/scale-.R +++ b/R/scale-.R @@ -231,9 +231,13 @@ discrete_scale <- function(aesthetics, scale_name = deprecated(), palette, name position <- arg_match0(position, c("left", "right", "top", "bottom")) # If the scale is non-positional, break = NULL means removing the guide - if (is.null(breaks) && all(!is_position_aes(aesthetics))) { + is_position <- any(is_position_aes(aesthetics)) + if (is.null(breaks) && !position) { guide <- "none" } + if (is_position && identical(palette, identity)) { + palette <- seq_len + } ggproto(NULL, super, call = call, From 7436002b4f60887e795a0dfe3ab61036b38ea838 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Mon, 8 Jul 2024 10:43:43 +0200 Subject: [PATCH 4/4] fix typo --- R/scale-.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/scale-.R b/R/scale-.R index 17f028c4ed..432bd6c7d5 100644 --- a/R/scale-.R +++ b/R/scale-.R @@ -232,7 +232,7 @@ discrete_scale <- function(aesthetics, scale_name = deprecated(), palette, name # If the scale is non-positional, break = NULL means removing the guide is_position <- any(is_position_aes(aesthetics)) - if (is.null(breaks) && !position) { + if (is.null(breaks) && !is_position) { guide <- "none" } if (is_position && identical(palette, identity)) {