scales icon indicating copy to clipboard operation
scales copied to clipboard

Feature request: palette registration

Open teunbrand opened this issue 2 years ago • 0 comments
trafficstars

I think it would be great if there was some mechanism in which packages can register a colour palette that then could natively interface with scales/ggplot2. It would save having to write separate scale_colour/fill_*() functions for packages providing the palettes, and save having to write scale_{custom_colour_aesthetic}_{palette_type} for packages that extend layers with custom colour-like aesthetics.

From a palette package POV you might then call

scales::register_palette(name = "foobar", type = "qualitative", fun = my_palette_fun)

This then gets stored in a list from which one could retrieve

scales::pal_registered(type = "qualitative", name = "foobar")

Which then gets used in e.g. ggplot2 scales. A nicety that can be added is to pre-populate these list of registered palettes with R's build-in palettes.

teunbrand avatar Sep 06 '23 09:09 teunbrand