Repository navigation
fix(scales): treat values outside discrete position limits as missing - #1160
Open
tushar-mahalya wants to merge 1 commit into
Open
tushar-mahalya wants to merge 1 commit into
tushar-mahalya wants to merge 1 commit into
Conversation
scale_position_discrete.map used nomatch=len(x) when matching values to the limits, so in a layer with fewer rows than the scale has limits an unmatched value was mapped to the position of an existing category instead of NaN.
This branch has not been deployed
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.
I ran into this while setting explicit limits on a discrete x scale. A value that isn't in the limits should be dropped, but in a small layer it gets drawn on top of one of the real categories instead:
On main this prints
[[2.0, 3.0]], so the red point sits on "b". With this branch it's[[nan, 3.0]]and the point is removed like any other missing value, which is what ggplot2 does.The cause is
nomatch=len(x)inscale_position_discrete.map. That goes back to the fix for #342, and it relies on the index running past the end of the position sequence so theIndexErrorbranch inserts NaN. That only happens when the layer has at least as many rows as the scale has limits, so smaller layers still get the #342 behaviour. I switched to the defaultnomatch=-1and turn negative indices into NaN, which also lets the try/except go.There's a scale-level test and one on the built layer data, both failing before the change, and a changelog entry. The rest of the suite matches main for me (the loess tests and the lint-subprocess tests fail locally only because scikit-misc and ruff aren't installed here).