8000 Un-mask any masked offsets by dstansby · Pull Request #14281 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Un-mask any masked offsets #14281

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def __init__(self,
self._uniform_offsets = None
if offsets is not None:
offsets = np.asanyarray(offsets, float)
offsets = np.ma.filled(offsets, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might happen to fix the scatter example, but I don't understand the logic of it--why should masked values in offsets be set to zero? I suspect the real problem with scatter and symlog is elsewhere. The points shouldn't be getting masked in the first place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, do you remember why you masked them in e959692 then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Originally, scatter handled masked values in any of its array inputs by forming a combined mask and then deleting the masked points from all of the arrays. The problem was that this led to a mismatch between the original input arrays and the plotted arrays, which caused trouble if the user subsequently tried to modify properties of the resulting collection. The solution was to let the collection handle the masked points instead of deleting them.
The problem that you are trying to fix here is only revealed, not caused, by this change--it is a problem related to an interaction between symlog and scatter, not a problem with the bad-value handling itself. It is related to the linear part of the symlog transformation. The mystery is why it shows up in scatter and not in plot. The points that are missing are those in the linear range; the default linthresh is 2.0, and the missing points are at 1 and 2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation, going down the rabbit hole was driving me a bit nuts! I agree this isn't the right fix here, so will close the PR.

# Broadcast (2,) -> (1, 2) but nothing else.
if offsets.shape == (2,):
offsets = offsets[None, :]
Expand Down
0