Skip to content

Commit 257ffaf

Browse files
authored
Guard against old discrete scales with identity palettes (#5933)
* rescue old palettes * Revert "rescue old palettes" This reverts commit 8031a33. * rescue in construction * fix typo
1 parent 1c1cdc3 commit 257ffaf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/scale-.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,13 @@ discrete_scale <- function(aesthetics, scale_name = deprecated(), palette, name
231231
position <- arg_match0(position, c("left", "right", "top", "bottom"))
232232

233233
# If the scale is non-positional, break = NULL means removing the guide
234-
if (is.null(breaks) && all(!is_position_aes(aesthetics))) {
234+
is_position <- any(is_position_aes(aesthetics))
235+
if (is.null(breaks) && !is_position) {
235236
guide <- "none"
236237
}
238+
if (is_position && identical(palette, identity)) {
239+
palette <- seq_len
240+
}
237241

238242
ggproto(NULL, super,
239243
call = call,

0 commit comments

Comments
 (0)