by_aesthetics.R refactor#539
Merged
vincentarelbundock merged 4 commits intograntmcdermott:mainfrom Jan 11, 2026
Merged
Conversation
grantmcdermott
requested changes
Jan 11, 2026
Owner
grantmcdermott
left a comment
There was a problem hiding this comment.
Just some minor namespace redundancies but otherwise LGTM.
Feel free to (squash and) merge when you're actioned.
Thanks Vincent!
R/by_aesthetics.R
Outdated
|
|
||
| # Map numeric indices to palette colors (unless ordered) | ||
| if (!ordered && is.numeric(cols)) { | ||
| base_pal = grDevices::palette() |
Owner
There was a problem hiding this comment.
We already import palette as part of our namespace, no?
R/by_aesthetics.R
Outdated
|
|
||
| if (is.null(palette_choice)) { | ||
| # Default palette selection (alpha applied at end) | ||
| base_pal = grDevices::palette() |
R/by_aesthetics.R
Outdated
| if (ngrps <= length(base_pal) && !ordered && !gradient) { | ||
| cols = base_pal[seq_len(ngrps)] | ||
| } else if (ngrps <= 8 && !ordered) { | ||
| cols = grDevices::palette.colors(n = ngrps, palette = "R4") |
R/by_aesthetics.R
Outdated
| } else if (ngrps <= 8 && !ordered) { | ||
| cols = grDevices::palette.colors(n = ngrps, palette = "R4") | ||
| } else if (!gradient && !ordered) { | ||
| cols = grDevices::hcl.colors(n = ngrps, palette = "Viridis") |
R/by_aesthetics.R
Outdated
| args = list(n = ngrps, palette = palette, alpha = alpha) | ||
| # Restricted viridis for gradient/ordered (excludes extreme ends) | ||
| cols = colorRampPalette( | ||
| grDevices::hcl.colors(n = 100, palette = "Viridis")[11:90], |
R/by_aesthetics.R
Outdated
| hcl.colors(n = 100, palette = "Viridis", alpha = alpha)[(100 * 0.1 + 1):(100 * 0.9)], | ||
| alpha = TRUE | ||
| )(ngrps) | ||
| grDevices::hcl.colors(max(cols))[cols] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Streamlining, DRY, and simplification for the
by_aesthetics()functions.Removed about 60 lines of code and made things (arguably) clearer.
TBC, there's absolutely no rush to review this. I just found some time to work on this (with Claude) this morning.