You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Re-adding annotation texts to the axes causes them to be obscured #31748
Hi! I'm a first-time contributor and I would love to work on this issue. Since add_artist automatically sets a clip path on the text annotations, I can look into modifying axes/_base.py to handle this better, or update the behavior for text artists. Could you please assign this to me?
This seems to be an error in clipping? Surely the clippibg logic should check if a._clipon is true or not. I'm clear why setting the clip box would or should make this clip. Conversely perhaps annotate is relying on the box rather than toggling clipping.
Yeah, but that means there are two toggles for clipping - if the path is None, or if a._clipon is False. It seems that if clipon is False the artist should still not be clipped, even if it does have a clip path. That seems to be the bug to me, not necessarily adding a default clip path?
Sorry, I'm not following. In the example, the user didn't specify clip_on, so it got set to True, but also annotate didn't set the box because clip_on wasn't in kwargs.
Then add_artist gets something that has clip_on True but no box set. So it adds the axes box because that makes sense for the majority of artists.
Thanks for the feedback and for taking a look at this! I see what you mean regarding how annotate initializes clip_on as True by default, and the broader point about how the rendering engine evaluates clip_on vs. the presence of a path.
I'll keep an eye on your discussion here and am happy to update this PR's implementation or shift it to a different file based on what you decide makes the most sense architecturally!
Sorry, I'm not following. In the example, the user didn't specify clip_on, so it got set to True, but also annotate didn't set the box because clip_on wasn't in kwargs.
Then add_artist gets something that has clip_on True but no box set. So it adds the axes box because that makes sense for the majority of artists.
Right, so I'm claiming that is buggy, probably because the clipping API wasn't fully developed when annotate was made.
Most artists: clip_on=True, clip_path=axes box
Annotate: clip_on=True (always!), clip_path=None unless annotation_clip=True and then it is axes box.
I'd argue instead that Annotate should default to clip_on=False, but have that be togglable, and set the clip_path like every other artist.
I guess if you default to clip_on=False, then any edge case where someone does want clipping in an annotation is a little more awkward because they have to set two things instead of one. I don’t know how likely it is that someone does that, but I also don’t know how likely it is that someone removes an annotation and re-adds it.
I would recommend setting the default clip box like we do for every other artist but just default to clip_on=False instead of clip_on=True. But maybe there is a subtlety I'm missing
Activity
rcomer commentedon May 26, 2026
add_artistautomatically sets a clip pathmatplotlib/lib/matplotlib/axes/_base.py
Lines 2359 to 2360 in f4cf125
If you really need to do this, you can explicitly turn clipping off
But, as stated in your previous issue, you may get what you want by just toggling the visibility rather than removing and re-adding artists.
BiswasNehaa commentedon May 26, 2026
Hi! I'm a first-time contributor and I would love to work on this issue. Since add_artist automatically sets a clip path on the text annotations, I can look into modifying axes/_base.py to handle this better, or update the behavior for text artists. Could you please assign this to me?
jklymak commentedon May 26, 2026
This seems to be an error in clipping? Surely the clippibg logic should check if a._clipon is true or not. I'm clear why setting the clip box would or should make this clip. Conversely perhaps annotate is relying on the box rather than toggling clipping.
rcomer commentedon May 26, 2026
Yes,
annotateonly sets the box if the user actively set clip_on toTruematplotlib/lib/matplotlib/axes/_axes.py
Lines 741 to 742 in f4cf125
Artistclip_on defaults toTrue. I guess having the defaultTrueallows the user to set a clip box/path without having to also toggle it on.jklymak commentedon May 26, 2026
Yeah, but that means there are two toggles for clipping - if the path is None, or if a._clipon is False. It seems that if clipon is False the artist should still not be clipped, even if it does have a clip path. That seems to be the bug to me, not necessarily adding a default clip path?
rcomer commentedon May 26, 2026
Sorry, I'm not following. In the example, the user didn't specify clip_on, so it got set to
True, but alsoannotatedidn't set the box because clip_on wasn't in kwargs.Then
add_artistgets something that has clip_onTruebut no box set. So it adds the axes box because that makes sense for the majority of artists.BiswasNehaa commentedon May 26, 2026
Thanks for the feedback and for taking a look at this! I see what you mean regarding how annotate initializes clip_on as True by default, and the broader point about how the rendering engine evaluates clip_on vs. the presence of a path.
I'll keep an eye on your discussion here and am happy to update this PR's implementation or shift it to a different file based on what you decide makes the most sense architecturally!
jklymak commentedon May 26, 2026
Right, so I'm claiming that is buggy, probably because the clipping API wasn't fully developed when annotate was made.
I'd argue instead that Annotate should default to clip_on=False, but have that be togglable, and set the clip_path like every other artist.
rcomer commentedon May 27, 2026
I guess if you default to clip_on=False, then any edge case where someone does want clipping in an annotation is a little more awkward because they have to set two things instead of one. I don’t know how likely it is that someone does that, but I also don’t know how likely it is that someone removes an annotation and re-adds it.
jklymak commentedon May 27, 2026
I would recommend setting the default clip box like we do for every other artist but just default to clip_on=False instead of clip_on=True. But maybe there is a subtlety I'm missing