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

Remove unused race/ethnicity categories from legend #142

Closed
nmpeterson opened this issue Feb 11, 2022 · 0 comments · Fixed by #143
Closed

Remove unused race/ethnicity categories from legend #142

nmpeterson opened this issue Feb 11, 2022 · 0 comments · Fixed by #143
Assignees
Labels
bug Something isn't working

Comments

@nmpeterson
Copy link
Contributor

Currently, if you create a chart using cmap_color_race(), the resulting legend will display all five categories (white, black, hispanic, asian, other), even if one of those categories is not present in the data/chart:

race_legend

I think there are two possible approaches for addressing this:

  1. Remove any default labels for the race/ethnicity categories, and only construct the palette from the label names that are explicitly supplied to cmap_color_race(). So cmap_color_race(white = "White", black = "Black") would yield a 2-item legend instead of 5 (with "hispanic", "asian" and "other" appearing by default). If none of the parameters were specified, an error would be returned saying that at least one must be.
  2. Add a new remove_missing boolean parameter. If it defaulted to FALSE, then cmap_color_race(white = "White", black = "Black") would still produce the same 5-item legend as the current function, but cmap_color_race(white = "White", black = "Black", remove_missing = TRUE) would then produce a 2-item legend.

I don't have strong feelings one way or the other. I'd be particularly interested to hear @gritzenthaler's thoughts on this one.

@nmpeterson nmpeterson added the bug Something isn't working label Feb 11, 2022
@leotorres114 leotorres114 self-assigned this Jul 19, 2022
@leotorres114 leotorres114 linked a pull request Jul 19, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants