8000 Do not set clip path if it exists · matplotlib/matplotlib@24c3802 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24c3802

Browse files
committed
Do not set clip path if it exists
1 parent 32b6ebb commit 24c3802

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,8 @@ def text(self, x, y, s, fontdict=None, **kwargs):
687687
**kwargs,
688688
}
689689
t = mtext.Text(x, y, text=s, **effective_kwargs)
690-
t.set_clip_path(self.patch)
690+
if t.get_clip_path() is None:
691+
t.set_clip_path(self.patch)
691692
self._add_text(t)
692693
return t
693694

@@ -700,7 +701,7 @@ def annotate(self, text, xy, xytext=None, xycoords='data', textcoords=None,
700701
textcoords=textcoords, arrowprops=arrowprops,
701702
annotation_clip=annotation_clip, **kwargs)
702703
a.set_transform(mtransforms.IdentityTransform())
703-
if 'clip_on' in kwargs:
704+
if kwargs.get('clip_on', False) and a.get_clip_path() is None:
704705
a.set_clip_path(self.patch)
705706
self._add_text(a)
706707
return a

lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,8 @@ def add_artist(self, a):
22182218
self._children.append(a)
22192219
a._remove_method = self._children.remove
22202220
self._set_artist_props(a)
2221-
a.set_clip_path(self.patch)
2221+
if a.get_clip_path() is None:
2222+
a.set_clip_path(self.patch)
22222223
self.stale = True
22232224
return a
22242225

@@ -2426,7 +2427,8 @@ def add_table(self, tab):
24262427
_api.check_isinstance(mtable.Table, tab=tab)
24272428
self._set_artist_props(tab)
24282429
self._children.append(tab)
2429-
tab.set_clip_path(self.patch)
2430+
if tab.get_clip_path() is None:
2431+
tab.set_clip_path(self.patch)
24302432
tab._remove_method = self._children.remove
24312433
return tab
24322434

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def add_artist(self, artist, clip=False):
508508
if not artist.is_transform_set():
509509
artist.set_transform(self.transSubfigure)
510510

511-
if clip:
511+
if clip and artist.get_clip_path() is None:
512512
artist.set_clip_path(self.patch)
513513

514514
self.stale = True

lib/matplotlib/patheffects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def draw_path(self, renderer, gc, tpath, affine, rgbFace):
368368
self.patch.set_transform(affine + self._offset_transform(renderer))
369369
self.patch.set_clip_box(gc.get_clip_rectangle())
370370
clip_path = gc.get_clip_path()
371-
if clip_path:
371+
if clip_path and self.patch.get_clip_path() is None:
372372
self.patch.set_clip_path(*clip_path)
373373
self.patch.draw(renderer)
374374

0 commit comments

Comments
 (0)
0