Yeah I've been meaning to file a bug or pr for... several years? Hah. Anyway I'm teaching a new class this quarter so there's already a bunch of ggdist issues on my plate that won't get touched for some time.
New approach:
scale_colorfill_viridis = reuse_scale(scale_color_viridis_c, c("color", "fill"))
ggplot(mtcars) +
aes(wt, mpg, color=hp, fill=hp) +
geom_point(shape=25, size=3, stroke=2) +
scale_colorfill_viridis()
Replace c("color", "fill") with any one or more color-based aesthetics you want.
I tested it by replacing all fill scales in the ggplot2 source with one-line calls to reuse_scale(scale_whatever_colour, "fill"). And it worked!
And that includes the default logic in scale_fill_continuous which determines what to do when the scale is unspecified. Everything is copied from colour.
I like this factory approach, but this wasn't the problem I meant - try mapping a continuous variable to the linecolor aesthetic. You should get an error in creating legend.
Yikes. That'll be phase 2:
github.com/tidyverse/gg...