ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

More `palette` flexibility

Open teunbrand opened this issue 1 year ago • 0 comments

This PR aims to fix #6064. Additionally it would also fix #6068 and fix #5843 and #2851.

The PR is a draft, as the {scales} version that powers this PR is not released yet. It adds a palette argument to the default discrete/binned/continuous colour/fill scales, which bypasses the . This palette is then internally converted with as_discrete_pal() or as_continuous_pal(). In the example below, we're using a single palette to populate all 3 types of scales.

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2
packageVersion("scales")
#> [1] '1.3.0.9000'

p <- ggplot(mpg, aes(displ, hwy, colour = cty)) +
  geom_point()

my_pal <- colour_ramp(c("cyan", "deepskyblue", "magenta"))

p + scale_colour_continuous(palette = my_pal)

p + scale_colour_binned(palette = my_pal)

p + scale_colour_discrete(palette = my_pal) +
  aes(colour = drv)

Created on 2024-09-17 with reprex v2.1.1

teunbrand avatar Sep 17 '24 11:09 teunbrand