ENH: Add TransformedPatchPath for clipping.#4920
Conversation
lib/matplotlib/transforms.py
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yeah, it seems you're really just implementing a more efficient TransformedPath, so subclassing in this case seems reasonable.
f5c9a96 to
7fb857a
Compare
|
OK, I changed it to be a subclass of |
7fb857a to
6366210
Compare
|
One more minor change; I forgot to re-cache the updated path when it changed. |
|
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. |
|
It's certainly possible. Cartopy seems to have 2 or 3 "background" patches though, so I wasn't sure which one to use. |
|
So "proposed next" is after 1.5, right? |
|
No, 2.1 On Sun, Sep 13, 2015, 14:42 Elliott Sales de Andrade <
|
|
👍 from me, but it should have a test, ideally something that tests whether the clipping path updates when the transform does. |
6366210 to
3d7f22c
Compare
|
Test added for both the new |
By linking to the Patch instead of its Path, the clip path can automatically update whenever the underlying Patch changes.
3d7f22c to
c2877b3
Compare
|
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. |
ENH: Add TransformedPatchPath for clipping.
|
👍 - thanks @QuLogic Thanks! |


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.