Repository navigation
feat: Support palette argument and palette.<aes>.* theme elements in pattern scales - #178
Merged
Merged
Conversation
… in pattern scales (#172) * Our `scale_pattern_*_discrete()` and `scale_pattern_*_continuous()` scales (and the ordinal, `scale_pattern_linetype()`, and `scale_pattern_shape()` scales) have a new `palette` argument which takes precedence over `choices` or `range`. * Like `{ggplot2}`'s own scales they now look up their palette in the `palette.<aesthetic>.discrete` or `palette.<aesthetic>.continuous` theme element when not given one. We register these theme elements for every pattern aesthetic with a scale when `{ggpattern}` is loaded and document them in the new `?pattern_palettes`. * The `choices`, `range`, and `solid` arguments now default to `NULL` so that the theme element can be used (the default palettes are unchanged). A scale without a default palette (e.g. `scale_pattern_type_discrete()`) now throws an error when it is used without one instead of when it is made. * A `palette` (or theme element) that is a vector `{scales}` can't convert into a palette is an error suggesting `scales::pal_manual()`, the `choices` or `range` argument, or the manual scale. * `scale_pattern_colour_discrete()`, `scale_pattern_fill_discrete()`, and `scale_pattern_fill2_discrete()` are no longer aliases of the `scale_pattern_*_hue()` scales and the continuous colour scales' colourbar now takes its `available_aes` from `aesthetics`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
trevorld
force-pushed
the
palette-theme-172
branch
from
November 20, 2026 23:26
642e273 to
8aa5167
Compare
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.
Closes #172.
Summary
scale_pattern_*_discrete()andscale_pattern_*_continuous()scales (and the ordinal scales,scale_pattern_linetype(), andscale_pattern_shape()) have a newpaletteargument. It takes precedence overchoicesorrange.{ggplot2}'s own scales, a scale created without a palette now looks one up in thepalette.<aesthetic>.discreteorpalette.<aesthetic>.continuoustheme element, e.g.theme(palette.pattern_type.discrete = c("hexagonal", "rhombille", "pythagorean")). These theme elements are registered for every pattern aesthetic with a scale when{ggpattern}is loaded. The new?pattern_paletteshelp page documents them.choices,range, andsolidnow default toNULLso that the theme element can be used. The default palettes are unchanged.scale_pattern_type_discrete(), now errors when it is used without a palette instead of when it is made.paletteargument or theme element that{scales}can't convert into a palette, such as a numeric vector, now errors with a hint: usescales::pal_manual(), thechoices/rangeargument, or the manual scale.scale_pattern_{colour,fill,fill2}_discrete()are no longer aliases of the_hue()scales, though they still accept their arguments.available_aesfromaesthetics, soaesthetics = "pattern_color"keeps its legend.The colour aesthetics have their own theme elements (
palette.pattern_fill.discreteetc.) rather than reusingpalette.fill.*. Otherwise mappingfillandpattern_fillto the same variable would draw patterns the same colour as their background.Follow-ups split out: #175 (ordered
pattern_shapescales), #176 (uneven continuouschoicesbins), #177 (no scales or theme palettes forpattern_option_*).Testing
paletteargument and theme element, and for the theme-element registration and class checks.R CMD check: 0 errors, 0 warnings, 0 notes.🤖 Generated with Claude Code