Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49b9504

Browse files
committed
Enable annotation clipping on invariant angle example.
Otherwise, panning around leaves the angle text visible even outside the Axes.
1 parent fa9fde9 commit 49b9504

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

examples/lines_bars_and_markers/angle_marker.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AngleMarker(Arc):
6969
Draws an arc between two vectors which appears circular in display space.
7070
"""
7171
def __init__(self, xy, p1, p2, size=75, unit="points", ax=None,
72-
text="", textposition="inside", text_kw={}, **kwargs):
72+
text="", textposition="inside", text_kw=None, **kwargs):
7373
"""
7474
Parameters
7575
----------
@@ -124,11 +124,11 @@ def __init__(self, xy, p1, p2, size=75, unit="points", ax=None,
124124
self.ax.add_patch(self)
125125

126126
self.kw = dict(ha="center", va="center",
127-
xycoords=IdentityTransform(), xytext=(0, 0),
128-
textcoords="offset points")
129-
self.kw.update(text_kw)
130-
self.text = ax.annotate(text, xy=self._center,
131-
**self.kw)
127+
xycoords=IdentityTransform(),
128+
xytext=(0, 0), textcoords="offset points",
129+
annotation_clip=True)
130+
self.kw.update(text_kw or {})
131+
self.text = ax.annotate(text, xy=self._center, **self.kw)
132132

133133
def get_size(self):
134134
factor = 1.
@@ -280,7 +280,8 @@ def plot_angle(ax, pos, angle, length=0.95, acol="C0", **kwargs):
280280
for x, text in zip([2.0, 3.5, 5.0, 6.5], ['"inside"', '"outside"', '"edge"',
281281
'"edge", custom arrow']):
282282
ax2.annotate(text, xy=(x, 0), xycoords=ax2.get_xaxis_transform(),
283-
bbox=dict(boxstyle="round", fc="w"), ha="left", fontsize=8)
283+
bbox=dict(boxstyle="round", fc="w"), ha="left", fontsize=8,
284+
annotation_clip=True)
284285

285286
#### SUBPLOT 3 ####
286287
# Showcase different size units. The effect of this can best be observed
@@ -297,7 +298,8 @@ def plot_angle(ax, pos, angle, length=0.95, acol="C0", **kwargs):
297298
for x, text in zip([2.0, 3.5, 5.0, 6.5], ['"pixels"', '"points"',
298299
'"axes min"', '"axes max"']):
299300
ax3.annotate(text, xy=(x, 0), xycoords=ax3.get_xaxis_transform(),
300-
bbox=dict(boxstyle="round", fc="w"), ha="left", fontsize=8)
301+
bbox=dict(boxstyle="round", fc="w"), ha="left", fontsize=8,
302+
annotation_clip=True)
301303

302304
plt.show()
303305

0 commit comments

Comments
 (0)