Skip to content

Commit 87ed95f

Browse files
committed
replace fallback mechanism
1 parent 1dd3c27 commit 87ed95f

File tree

3 files changed

+2
-30
lines changed

3 files changed

+2
-30
lines changed

R/scale-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ Scale <- ggproto("Scale", NULL,
598598
if (empty(df)) {
599599
return()
600600
}
601-
self$palette <- self$palette %||% fallback_palette(self)
601+
self$palette <- self$palette %||% fetch_ggproto(self, "fallback_palette")
602602

603603
aesthetics <- intersect(self$aesthetics, names(df))
604604
names(aesthetics) <- aesthetics

R/scales-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ ScalesList <- ggproto("ScalesList", NULL,
183183
elem <- compact(lapply(elem, calc_element, theme))[1][[1]]
184184

185185
# Resolve the palette itself
186-
elem <- elem %||% fallback_palette(scale)
186+
elem <- elem %||% fetch_ggproto(scale, "fallback_palette")
187187
palette <- switch(
188188
type,
189189
discrete = as_discrete_pal(elem),

R/utilities.R

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -810,34 +810,6 @@ size0 <- function(x) {
810810
}
811811
}
812812

813-
fallback_palette <- function(scale) {
814-
aes <- scale$aesthetics[1]
815-
discrete <- scale$is_discrete()
816-
if (discrete) {
817-
pal <- switch(
818-
aes,
819-
colour = , fill = pal_hue(),
820-
alpha = function(n) seq(0.1, 1, length.out = n),
821-
linewidth = function(n) seq(2, 6, length.out = n),
822-
linetype = pal_linetype(),
823-
shape = pal_shape(),
824-
size = function(n) sqrt(seq(4, 36, length.out = n)),
825-
ggplot_global$theme_default[[paste0("palette.", aes, ".discrete")]]
826-
)
827-
return(pal)
828-
}
829-
switch(
830-
aes,
831-
colour = , fill = pal_seq_gradient("#132B43", "#56B1F7"),
832-
alpha = pal_rescale(c(0.1, 1)),
833-
linewidth = pal_rescale(c(1, 6)),
834-
linetype = pal_binned(pal_linetype()),
835-
shape = pal_binned(pal_shape()),
836-
size = pal_area(),
837-
ggplot_global$theme_default[[paste0("palette.", aes, ".continuous")]]
838-
)
839-
}
840-
841813
warn_dots_used <- function(env = caller_env(), call = caller_env()) {
842814
check_dots_used(
843815
env = env, call = call,

0 commit comments

Comments
 (0)