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

Feature request: centered palettes #50

Open
wetlandscapes opened this issue Aug 15, 2019 · 0 comments
Open

Feature request: centered palettes #50

wetlandscapes opened this issue Aug 15, 2019 · 0 comments

Comments

@wetlandscapes
Copy link

I was thinking it would be kind of neat to have an option in which colors were assigned from the middle of a palette, rather than from the left (i.e., direction = 1) or right (i.e., direction = -1).

For example say we wanted to use the following palette, but we only had three colors:

paletteer_d(ggthemes, hc_bg)
[1] "#d5e4eb" "#c3d6df" "#ed111a" "#ebebeb" "#c9c9c9"

Normally we'd do something like:

paletteer_d(ggthemes, hc_bg, n = 3) #or possibly paletteer_d(ggthemes, hc_bg, n = 3, direction = -1)
[1] "#d5e4eb" "#c3d6df" "#ed111a"

But what if we wanted to use the middle three colors? Usually I'd do something like:

paletteer_d(ggthemes, hc_bg)[c(2:4)]
[1] "#c3d6df" "#ed111a" "#ebebeb"

That's not terrible, but it can be inconvenient if dealing with a lot of changing group conditions.

What about an even number of groups? Could include an argument for starting from the left or the right of the middle color. Maybe even one for dropping the middle color. This could include similar logic for an even number of colors and an odd number of groups.

Thus, I could see a modification of the paletteer_* functions to include some new arguments:

paletteer_d(..., centered = c(TRUE, FALSE), side = c("left", "right", "middle"))
#Examples of functionality:
paletteer_d(ggthemes, hc_bg, n = 3, centered = TRUE) #original color index: [2, 3, 4]
[1] "#c3d6df" "#ed111a" "#ebebeb"
paletteer_d(ggthemes, hc_bg, n = 4, centered = TRUE, side = "left") #original color index: [1, 2, 3, 4]
[1] "#d5e4eb" "#c3d6df" "#ed111a" "#ebebeb"
paletteer_d(ggthemes, hc_bg, n = 4, centered = TRUE, side = "right") #original color index: [2, 3, 4, 5]
[1] "#c3d6df" "#ed111a" "#ebebeb" "#c9c9c9"
paletteer_d(ggthemes, hc_bg, n = 4, centered = TRUE, side = "middle") #original color index: [1, 2, 4, 5]
[1]  "#d5e4eb" "#c3d6df" "#ebebeb" "#c9c9c9"

Thoughts?

@EmilHvitfeldt EmilHvitfeldt added new palettes New palettes to be included and removed new palettes New palettes to be included labels Dec 7, 2019
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

No branches or pull requests

2 participants