-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
text is not clipped by clip_path #8270
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
Comments
The first culprit occurs in _AxesBase.add_artist
or, if calling
i.e., when adding the text object to the axes, the clip path is simply dropped, and replaced by the axes clip path. (I think we should just not set the clip path if it is already set.) But even delaying the setting of the clip path until after the artist is added to the axes does not seem to help. I suspect there are some issues with Artist.set_clip_path, which is handling a bunch of different cases, but am not certain of that. |
As commented above diff --git i/lib/matplotlib/axes/_base.py w/lib/matplotlib/axes/_base.py
index aec405415..4206956d7 100644
--- i/lib/matplotlib/axes/_base.py
+++ w/lib/matplotlib/axes/_base.py
@@ -1898,7 +1898,8 @@ class _AxesBase(martist.Artist):
self.artists.append(a)
a._remove_method = self.artists.remove
self._set_artist_props(a)
- a.set_clip_path(self.patch)
+ if a.get_clip_path() is None:
+ a.set_clip_path(self.patch)
self.stale = True
return a is a first necessary step to fix this (this is consistent with e.g. add_line(); there's a few other places (e.g. add_table(), text(), etc.) where we call set_clip_path without checking a previously existing clip path and should likewise be fixed. |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
#8270 (comment) has been integrated, but as noted this is not enough for agg. |
Bug report
Bug summary
I expect that a matplotlib.text.Text object should disappear when clipped by setting
clip_path=some_path
. In practice, the text is still here.Code for reproduction
Actual outcome
Expected outcome
I would expect the text
outside :(
not to appear on the image.Matplotlib version
This happens with matplotlib 2.0.0 with python 3.6.0 (installed with anaconda on linux). It also happens with matplotlib 1.5.3 with python 3.5.2 (same setup).
The text was updated successfully, but these errors were encountered: