From f00601e685b1a875939234a746268f499e45d1e9 Mon Sep 17 00:00:00 2001 From: Kara Woo Date: Thu, 25 Jun 2020 17:16:41 -0700 Subject: [PATCH] More accurate check for palette names Some of the names can be NA if more colors are requested than are present in the palette. is_named() would return FALSE in this case, so it's changed here to `!is_null(names(pal))`. --- R/scale-.r | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/scale-.r b/R/scale-.r index e77179ed7c..801b839109 100644 --- a/R/scale-.r +++ b/R/scale-.r @@ -806,7 +806,7 @@ ScaleDiscrete <- ggproto("ScaleDiscrete", Scale, self$n.breaks.cache <- n } - if (is_named(pal)) { + if (!is_null(names(pal))) { # if pal is named, limit the pal by the names first, # then limit the values by the pal idx_nomatch <- is.na(match(names(pal), limits))