Repository navigation
fix: Continuous choices scales split the data into equal-width bins (#176) - #179
Merged
Merged
Conversation
…#176) * `scale_pattern_continuous()` and the `scale_pattern_*_continuous()` scales that pick from `choices` previously only used the last choice at the maximum (`pal_choices_continuous()` truncated over `length(choices) - 1` steps). * `pal_choices_continuous()` now splits [0, 1] into `length(choices)` equal-width bins closed on the right like `{ggplot2}`'s binned scales and `pal_choices_discrete()` (so evenly spaced values get the same choices as the discrete scale gives them as a factor). A value within `sqrt(.Machine$double.eps)` of a bin width of an edge counts as on it (like the `fuzz` of `hist()`) so that edges aren't missed because of rounding error. * Values outside [0, 1] (e.g. with `oob = scales::oob_keep`) are now `NA` like in `{ggplot2}`'s binned scales. * The `choices` documentation now describes how continuous scales bin values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mage.Rmd.orig` * `patterns-image.Rmd.orig` now has the updated aesthetic defaults tables that 321e8b3 only made to the knitted `patterns-image.Rmd` (so precomputing the vignette no longer reverts them). * The `geom_bin2d_pattern()` gallery examples now show the "Removed 7 rows containing missing values" warning that `GeomTilePattern` now gives like `ggplot2::geom_bin2d()`. * The precomputed images aren't updated yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #176.
pal_choices_continuous()(used byscale_pattern_continuous()and thescale_pattern_*_continuous()scales that pick fromchoices) now splits [0, 1] intolength(choices)equal-width bins instead of only using the last choice at the maximum.For
1:10with three choices this gives 4, 3, and 3 values (previously 5, 4, and 1).{ggplot2}'s binned scales and ourpal_choices_discrete(), so evenly spaced values get the same choices as the discrete scale gives them as a factor.This differs from the 3, 3, 4 split proposed in Continuous
choicesscales give the last choice only at the maximum #176.sqrt(.Machine$double.eps)of a bin width of an edge counts as on it (like thefuzzofhist()).Plain
ceiling(x * n)misbinned 287 of 3894 evenly spaced test cases because of rounding error (e.g. a rescaled 0.6 times 5 is 3.0000000000000004), andcut()withseq()breaks misbinned 415.oob = scales::oob_keep) are nowNAon both sides like in{ggplot2}'s binned scales (previouslyNAabove andchoices[0]or negative indices below).choicesdocs now describe how continuous scales bin values, and NEWS lists this under breaking changes since some values now get a different choice.A second commit syncs
vignettes/patterns-image.Rmd.origwith the defaults tables 321e8b3 made only to the knitted.Rmd, and adds the "Removed 7 rows" warning (whichggplot2::geom_bin2d()gives too) to the bin2d gallery examples.The precomputed vignette images are deliberately not updated yet (to be regenerated before the CRAN release).
🤖 Generated with Claude Code