Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named palettes #448

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

Named palettes #448

wants to merge 13 commits into from

Conversation

teunbrand
Copy link
Contributor

This PR aims to fix #396.

Briefly, it adds a register of known palettes.

In some more detail, you can get one of the known palettes with get_palette(), set a new known palette with set_pallette(), see all known palettes with palette_names() and restore the default palettes with reset_palettes(). Along with these functions, there is integration with as_continuous/discrete_pal() and show_col() to work with known palettes.

The nice thing about having known palettes, is that you can refer to them by name.

devtools::load_all("~/packages/scales/")
#> ℹ Loading scales
show_col("Okabe-Ito")

This PR would nicely integrate with tidyverse/ggplot2#6112, as it would use as_continuous/discrete_pal() in the default colour scales.

pal <- as_discrete_pal("magma")
show_col(pal(16))

Palette packages are then able to register their own palettes, which you could then also refer to by name.

cols <- c("palegreen", "deepskyblue", "magenta")
set_palette("aurora", palette = cols)
show_col(as_continuous_pal("aurora"), labels = FALSE)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: palette registration
1 participant