Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: Add TransformedPatchPath for clipping. #4920

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 2 commits into from
Oct 30, 2015

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Aug 14, 2015

By linking to the Patch instead of its Path, the clip path can automatically update whenever the underlying Patch changes.

This is an attempt to fix #4788; I'm not sure if this is the best method to do so, but it works pretty well with the polar plots.

'should_simplify': patch_path.should_simplify})
self._invalid = 0

def get_transformed_points_and_affine(self):
Copy link
Member Author

Choose a reason for hiding this comment

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

Now that I'm looking at it as a whole, maybe TransformedPatchPath should derive from TransformedPath so I don't have to duplicate these get_transformed* methods. Though maybe the meaning is a bit off that way.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it seems you're really just implementing a more efficient TransformedPath, so subclassing in this case seems reasonable.

@tacaswell tacaswell added this to the proposed next point release milestone Aug 14, 2015
@tacaswell
Copy link
Member

attn @mdboom @pelson

@QuLogic
Copy link
Member Author

QuLogic commented Aug 29, 2015

OK, I changed it to be a subclass of TransformedPath.

@QuLogic
Copy link
Member Author

QuLogic commented Aug 29, 2015

One more minor change; I forgot to re-cache the updated path when it changed.

@pelson
Copy link
Member

pelson commented Sep 3, 2015

I'm 👍 on this change @QuLogic. Just out of curiosity, have you had a look at how this impacts Cartopy, which to my knowledge is the biggest user of matplotlib's non-affine transforms? Also, it may be that the example in https://github.com/SciTools/cartopy/blob/master/lib/cartopy/examples/favicon.py#L19 no longer needs to recompute the clip path with this change.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 4, 2015

It's certainly possible. Cartopy seems to have 2 or 3 "background" patches though, so I wasn't sure which one to use.

@QuLogic
Copy link
Member Author

QuLogic commented Sep 13, 2015

So "proposed next" is after 1.5, right?

@tacaswell
Copy link
Member

No, 2.1

On Sun, Sep 13, 2015, 14:42 Elliott Sales de Andrade <
[email protected]> wrote:

So "proposed next" is after 1.5, right?


Reply to this email directly or view it on GitHub
#4920 (comment)
.

@mdboom
Copy link
Member

mdboom commented Oct 6, 2015

👍 from me, but it should have a test, ideally something that tests whether the clipping path updates when the transform does.

@QuLogic
Copy link
Member Author

QuLogic commented Oct 19, 2015

Test added for both the new TransformedPatchPath and the older TransformedPath which didn't really have one directly.

By linking to the Patch instead of its Path, the clip path can
automatically update whenever the underlying Patch changes.
@mdboom
Copy link
Member

mdboom commented Oct 19, 2015

Thanks. I'm happy to merge this, but first have @QuLogic and/or @pelson answered the question about any ill effects on cartopy?

@QuLogic
Copy link
Member Author

QuLogic commented Oct 24, 2015

Unfortunately, it is difficult to say with any certainty, because Cartopy's tests for MPL integration do not pass with 1.4+. But at the very least, nothing has broken.

@QuLogic
Copy link
Member Author

QuLogic commented Oct 29, 2015

After updating Cartopy's tests to work with 1.5, it seems that there is one test with a failure, though it is small:
result-pcolormesh_limited_area_wrap
result-pcolormesh_limited_area_wrap-failed-diff

When the tolerance is turned down in matplotlib, a few more test images here might fail too if the same thing happens. It seems to be a rounding error at half-pixels. If I make the same plot interactively and resize, it alternatively comes and goes. But I'm not sure why, since the calculation should be about the same between the two.

pelson added a commit that referenced this pull request Oct 30, 2015
ENH: Add TransformedPatchPath for clipping.
@pelson pelson merged commit de19d5c into matplotlib:master Oct 30, 2015
@pelson
Copy link
Member

pelson commented Oct 30, 2015

👍 - thanks @QuLogic
Would you mind adding another PR which puts a whats new entry in the docs.

Thanks!

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

Successfully merging this pull request may close these issues.

Modified axes patch will not re-clip artists
4 participants