Brenton Wiernik@bwiernik.bsky.social·2023-10-10T15:40:10.604Z#
1. I would suggest just leveraging the scale_color_*(aesthetics = "bordercolor") syntax for these niche color aesthetics (the way a lot of extension packages are starting to)
Brenton Wiernik@bwiernik.bsky.social·2023-10-10T15:40:47.722Z#
2. It would be much less frustrating for users if it were a true aesthetic (eg, white vs black border for stat sig, being able to apply stage() for color tweaking for readability). That would be more valuable than a fallback default if both aren’t possible.
Brenton Wiernik@bwiernik.bsky.social·2023-10-10T15:41:35.847Z#
2b. Personally I would expect NULL to mean no additional border, not a border of the same color as the initial text (unless I’m misunderstanding something)
Steve Haroz@steveharoz.com·2023-10-10T15:58:27.818Z#
NA makes it transparent (no border).
Anyway, it's a good point about making it a true aesthetic.
Matthew Kay@mjskay.com·2023-10-10T16:45:04.393Z#
Relatedly, does guide_colorbar still complain about being applied to non-standard color aesthetics? That was one problem with using scale_color on them that should be fixed
Steve Haroz@steveharoz.com·2023-10-10T16:59:37.111Z#
Got a simple version working. No warnings or messages!
ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
geom_label(aes(colour = factor(cyl), linecolour = factor(cyl))) +
scale_color_manual(values = c("red", "green", "blue"), aesthetics = c("colour", "linecolour"))
Brenton Wiernik@bwiernik.bsky.social·2023-10-10T16:59:56.513Z#
Amazing!
Brenton Wiernik@bwiernik.bsky.social·2023-10-10T17:02:14.493Z#
Does it work to set different color scales for color and linecolor?
scale_color_manual(values = c(“red”, “blue”, “green”), aesthetics = “color”) +
scale_color_manual(values = c(“black”, “white”), aesthetics = “linecolor”)
Matthew Kay@mjskay.com·2023-10-13T05:15:17.172Z#
Try it with a continuous color scale (i.e. one that uses guide_colorbar not guide_legend). It should give the error "Guide `colorbar` cannot be used for linecolour" because colorbar hardcodes the aesthetics it is allowed to be used for, which makes it annoying to use with extension packages.
Brenton Wiernik@bwiernik.bsky.social·2023-10-13T11:04:50.177Z#
That detection should probably use a regex like /(colou?r)|(fill)/
Matthew Kay@mjskay.com·2023-10-13T15:10:20.343Z#
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.
Steve Haroz@steveharoz.com·2023-10-13T13:51:18.498Z#
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.