8000 Don't disable path clipping on paths with codes. by QuLogic · Pull Request #20363 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Don't disable path clipping on paths with codes. #20363

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 11, 2021

Conversation

QuLogic
Copy link
Member
@QuLogic QuLogic commented Jun 4, 2021

PR Summary

When PathClipper is applied, it is disabled if has_curves() is true. However, that method simply checks if the Path has codes, not curves. This means Paths created with codes, but using only MOVETO/LINETO, are not clipped when they could be.

Additionally, the description for PathClipper says that "Curve segments are not clipped, but are always included in their entirety.", meaning there is no need to turn it off when the Path contains curves, as they will at least be handled, if not fully clipped.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [n/a] New features are documented, with examples if plot related.
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

@QuLogic QuLogic added this to the v3.5.0 milestone Jun 4, 2021
@anntzer
Copy link
Contributor
anntzer commented Jun 4, 2021

Seems good. Do you know if there's any other uses of has_curves() that should likewise be fixed?

@QuLogic
Copy link
Member Author
QuLogic commented Jun 4, 2021

It's also passed to PathNanRemover, but that just triggers a slow path. Maybe we could optimize that, but it's not as easy.

Copy link
Member
@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

A bit concerned that that image changed. I assume that is because something used to be clipped an there is a pixel or two that changed at the edges?

@QuLogic
Copy link
Member Author
QuLogic commented Jun 4, 2021

The change is in the last Axes:
tickedstroke-failed-diff

These three paths are from contour, and have Path.codes, but they are all MOVETO + LINETO. I think that is due to a somewhat-recent change to produce full codes on contours. So they should have been clipped, but weren't, and I guess this produces a minuscule change in the simplified path post-clipping.

@anntzer
Copy link
Contributor
anntzer commented Jun 5, 2021

would e.g. setting rcParams["path.simplify_threshold"] (or setting the simplification threshold in some other manner) avoid that?

@QuLogic
Copy link
Member Author
QuLogic commented Jun 10, 2021

Unfortunately not, tuning it down to 0 still fails at about 0.588 RMS, and thresholds in between are still a bit off.

@anntzer
Copy link
Contributor
anntzer commented Jun 10, 2021

I guess I could live with putting that tol here.

When `PathClipper` is applied, it is disabled if `has_curves()` is true.
However, that method simply checks if the Path has _codes_, not curves.
This means Paths created with codes, but using only MOVETO/LINETO, are
not clipped when they could be.

Additionally, the description for `PathClipper` says that "Curve
segments are not clipped, but are always included in their entirety.",
meaning there is no need to turn it off when the Path contains curves,
as they will at least be handled, if not fully clipped.
@QuLogic QuLogic force-pushed the clip-allow-codes branch from 1918143 to 81aa223 Compare June 11, 2021 00:41
@QuLogic
Copy link
Member Author
QuLogic commented Jun 11, 2021

Done, actually default simplify threshold is even lower RMS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0