Skip to content

Process clip paths the same way as regular Paths. #15970

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
Dec 20, 2019

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Dec 18, 2019

PR Summary

Specifically, run NaN removal, clipping to figure boundary, snapping to pixel centers, and path simplification on it.

This means if you plot a Path, and then clip some other artist with it, you will get properly aligned results.

I'm not entirely sure whether it makes sense to run NaN removal and figure clipping on the clip path, but I put them in for consistency with other paths. There don't seem to be any tests that are affected by these two. The change to lib/matplotlib/tests/baseline_images/test_offsetbox/offsetbox_clipping.png is because the clip path is snapped and better aligns with the other path. The change to lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.png is a minor effect of path simplification on the clip path.

Fixes #15952. It also fixes the problem in Cartopy (see SciTools/cartopy#1422) for some cases, but not all. I'll need to investigate that a bit further.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Specifically, run NaN removal, clipping to figure boundary, snapping to
pixel centers, and path simplification on it.

This means if you plot a Path, and then clip some other artist with it,
you will get properly aligned results.
Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Seems straightforward enough, though I'm by no means an expert on the Agg code...

@anntzer
Copy link
Contributor

anntzer commented Dec 18, 2019

mplcairo does the same (but that was really an accidental, though welcome, side effect of having a single python-path -> c++ path loader).

@anntzer
Copy link
Contributor

anntzer commented Dec 18, 2019

@QuLogic milestone this to whatever sounds good to you and merge yourself?

@QuLogic
Copy link
Member Author

QuLogic commented Dec 20, 2019

Well, my preference is as far back as possible for Cartopy's sake, of course, but it's difficult to assess the effect since so little of the library uses clip paths itself.

@dopplershift
Copy link
Contributor

I think this can quite reasonably be called a bug fix. And having it in 3.2 would make it easier to get something into the next CartoPy release...

@tacaswell tacaswell added this to the v3.2.0 milestone Dec 20, 2019
@tacaswell
Copy link
Member

Getting 3.2 rc3 tagged, published and publicized is on my to-do for this weekend.

@dopplershift dopplershift merged commit ce7115d into matplotlib:master Dec 20, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 20, 2019
timhoffm added a commit that referenced this pull request Dec 20, 2019
…970-on-v3.2.x

Backport PR #15970 on branch v3.2.x (Process clip paths the same way as regular Paths.)
@QuLogic QuLogic deleted the clippath-processing branch December 21, 2019 05:15
QuLogic added a commit to QuLogic/cartopy that referenced this pull request Jan 7, 2020
This is the only test that is affected by matplotlib/matplotlib#15970.
The new image is correct, but the difference is small enough to just
change the tolerance.
QuLogic added a commit to QuLogic/cartopy that referenced this pull request Jan 7, 2020
This is the only test that is affected by matplotlib/matplotlib#15970.
The new image is correct, but the difference is small enough to just
change the tolerance.
QuLogic added a commit to QuLogic/cartopy that referenced this pull request Jan 7, 2020
This is the only test that is affected by matplotlib/matplotlib#15970.
The new image is correct, but the difference is small enough to just
change the tolerance.
kacmak7 pushed a commit to kacmak7/cartopy that referenced this pull request Feb 26, 2020
This is the only test that is affected by matplotlib/matplotlib#15970.
The new image is correct, but the difference is small enough to just
change the tolerance.
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.

Images are clipped incorrectly with custom clip path
4 participants