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

Specify column grouping for color palettes #1826

Open
2 tasks done
jmlondon opened this issue Aug 12, 2024 · 0 comments
Open
2 tasks done

Specify column grouping for color palettes #1826

jmlondon opened this issue Aug 12, 2024 · 0 comments
Assignees

Comments

@jmlondon
Copy link

Prework

Proposal

During the posit::conf 2024 workshop we discussed how the color palette domain (when not specified) is calculated based on the minimum and maximum values within each column. This makes sense as a default given gt doesn't know whether particular columns share a domain so best to presume each column has an independent domain. There are situations, however, when the visualization would benefit from columns sharing a domain so values are consistent and comparable across columns. The initial suggestion in our discussion was to add some sort of grouping argument that could accept a list of columns (or tidy select function e.g. starts_with, ends_with,contains). In this situation, gt would calculate the domain based on the range of values across all of those columns and, then, create the color gradient.

This is currently possible with a custom function that calculates the domain and, then, that range is passed along to the domain argument. Integrating this within data_color() would be more user friendly.

example possible code

gt(exibble) |> 
data_color(columns = c(currency,num),
           palette = c("red","blue")#,
           #grouping = c(currency,num)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants