Skip to content

Commit 9a86e82

Browse files
committed
Do not set clip path if it exists
1 parent 028f07c commit 9a86e82

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
@@ -673,7 +673,8 @@ def text(self, x, y, s, fontdict=None, **kwargs):
673673
**kwargs,
674674
}
675675
t = mtext.Text(x, y, text=s, **effective_kwargs)
676-
t.set_clip_path(self.patch)
676+
if t.get_clip_path() is None:
677+
t.set_clip_path(self.patch)
677678
self._add_text(t)
678679
return t
679680

@@ -686,7 +687,7 @@ def annotate(self, text, xy, xytext=None, xycoords='data', textcoords=None,
686687
textcoords=textcoords, arrowprops=arrowprops,
687688
annotation_clip=annotation_clip, **kwargs)
688689
a.set_transform(mtransforms.IdentityTransform())
689-
if 'clip_on' in kwargs:
690+
if kwargs.get('clip_on', False) and a.get_clip_path() is None:
690691
a.set_clip_path(self.patch)
691692
self._add_text(a)
692693
return a

lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,8 @@ def add_artist(self, a):
22242224
self._children.append(a)
22252225
a._remove_method = self._children.remove
22262226
self._set_artist_props(a)
2227-
a.set_clip_path(self.patch)
2227+
if a.get_clip_path() is None:
2228+
a.set_clip_path(self.patch)
22282229
self.stale = True
22292230
return a
22302231

@@ -2433,7 +2434,8 @@ def add_table(self, tab):
24332434
self._deprecate_noninstance('add_table', mtable.Table, tab=tab)
24342435
self._set_artist_props(tab)
24352436
self._children.append(tab)
2436-
tab.set_clip_path(self.patch)
2437+
if tab.get_clip_path() is None:
2438+
tab.set_clip_path(self.patch)
24372439
tab._remove_method = self._children.remove
24382440
return tab
24392441

lib/matplotlib/figure.py

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

504-
if clip:
504+
if clip and artist.get_clip_path() is None:
505505
artist.set_clip_path(self.patch)
506506

507507
self.stale = True

lib/matplotlib/patheffects.py

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

0 commit comments

Comments
 (0)