8000 fix markevery plot option with nans in data by rc · Pull Request #22519 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

fix markevery plot option with nans in data #22519

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

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions lib/matplotlib/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ def _slice_or_none(in_v, slc):
raise ValueError(
"markevery is specified relative to the axes size, but "
"the line does not have a Axes as parent")

# calc cumulative distance along path (in display coords):
disp_coords = affine.transform(tpath.vertices)
fin = np.isfinite(verts).all(axis=1)
fverts = verts[fin]
disp_coords = affine.transform(fverts)
Copy link
Member

Choose a reason for hiding this comment

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

This seems the easiest, and has the feature of only testing shown markers for visual distance. Not always what folks want, but at least doesn't error, and has the benefit of simplicity.

Copy link
Member

Choose a reason for hiding this comment

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

Are you ok with this @rc or did you want to argue for a different algorithm? @oscargus this changed since your approval. Still OK?

Copy link
Member

Choose a reason for hiding this comment

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

Still OK! I think we have similar views: no error thrown and some output that makes sense (although it is and always will be possible to find cases that gives "sub-optimal" results).

And nicer with a shorter/simpler solution as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is OK!

Copy link
Member

Choose a reason for hiding this comment

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

@rc can you squash to one commit, and then I will merge... If you have not done a rebase before, make sure to make a backup branch so you can get back to this point. But basically

git fetch upstream
git rebase -i upstream/master

and choose squash for all your commits except the first one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


delta = np.empty((len(disp_coords), 2))
delta[0, :] = 0
delta[1:, :] = disp_coords[1:, :] - disp_coords[:-1, :]
Expand All @@ -174,7 +178,7 @@ def _slice_or_none(in_v, slc):
inds = inds.argmin(axis=1)
inds = np.unique(inds)
# return, we are done here
return Path(verts[inds], _slice_or_none(codes, inds))
return Path(fverts[inds], _slice_or_none(codes, inds))
else:
raise ValueError(
f"markevery={markevery!r} is a tuple with len 2, but its "
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
0