-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: fastpath clipped artists #14445
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
FIX: fastpath clipped artists #14445
Conversation
lib/matplotlib/artist.py
Outdated
@@ -249,6 +249,23 @@ def get_window_extent(self, renderer): | |||
""" | |||
return Bbox([[0, 0], [0, 0]]) | |||
|
|||
def get_clip_bbox_extents(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps call this get_clip_extents
? (otherwise it's not clear whether it's just the extents of the clip box or of the intersection of the clip_box and the clip_path)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about get_clip_bbox
. I guess this should also be private, just so we don't have to worry about changing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for private as usual ;)
get_clip_bbox sounds too close to get_clip_box to me...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, private and _get_clipping_extent_bbox
was what I decided on. It is an extent (rather than the actual clip path) and it returns a Bbox
.
f6dbc7f
to
c4c7473
Compare
Trying to sneak in to 3.1.1 since this can be a pretty big speedup for some cases. But not Release Critical if it doesn't get in... |
lib/matplotlib/artist.py
Outdated
@@ -249,6 +249,23 @@ def get_window_extent(self, renderer): | |||
""" | |||
return Bbox([[0, 0], [0, 0]]) | |||
|
|||
def _get_clipping_extent_bbox(self): | |||
""" | |||
Return the intersection of the clip_path and clip_box for this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Return the extents of the intersection..."
lib/matplotlib/artist.py
Outdated
def _get_clipping_extent_bbox(self): | ||
""" | ||
Return the intersection of the clip_path and clip_box for this | ||
artist. Returns None if both of these are None, or ``get_clip_on`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
", or None if either..."
lib/matplotlib/axes/_base.py
Outdated
if clip_extent is not None: | ||
clip_extent = mtransforms.Bbox.intersection(clip_extent, | ||
axbbox) | ||
inside_axes = np.all(clip_extent.extents == axbbox.extents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not inside_axes: continue
and then below you don't need to re-check for Noneness of clip_extent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored to make this cleaner...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... though I have a mild aversion to continue
. Somewhere I got accustomed to continue
being bad style...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor style points, but overall looks nice.
c4c7473
to
1f889a8
Compare
1f889a8
to
2eb6772
Compare
Thanks @jklymak ! |
…445-on-v3.1.x Backport PR #14445 on branch v3.1.x (FIX: fastpath clipped artists)
PR Summary
In 3.x
ax.get_tightbbox()
started to include all artists on the axes when it was called. This is an expected performance hit. @tacaswell suggested that perhaps if the artist is clipped by the axes patch this is not necessary.The change here implements that solution - if the artist is clipped and the clip path is contained in the axes clip path, then
artist.get_tightbbox()
is no longer called for that artist.Example:
Old:
18.68
New:
0.4187
PR Checklist