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

Skip to content

Commit 28770ba

Browse files
committed
Fix positioning of annotation arrow.
Reverts one change from 47f741e and adds a comment why it should not be removed. The choice of test to change might be a surprise, but most of our arrow-in-annotation tests use empty text, which would not trigger the bug. Changing this image has a much smaller effect than adding text to one of those would.
1 parent 7cc1e72 commit 28770ba

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

632 Bytes
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4913,9 +4913,10 @@ def test_pie_center_radius():
49134913
autopct='%1.1f%%', shadow=True, startangle=90,
49144914
wedgeprops={'linewidth': 0}, center=(1, 2), radius=1.5)
49154915

4916-
plt.annotate("Center point", xy=(1, 2), xytext=(1, 1.5),
4916+
plt.annotate("Center point", xy=(1, 2), xytext=(1, 1.3),
49174917
arrowprops=dict(arrowstyle="->",
4918-
connectionstyle="arc3"))
4918+
connectionstyle="arc3"),
4919+
bbox=dict(boxstyle="square", facecolor="lightgrey"))
49194920
# Set aspect ratio to be equal so that pie is drawn as a circle.
49204921
plt.axis('equal')
49214922

lib/matplotlib/text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,10 @@ def draw(self, renderer):
19491949
self._renderer = renderer
19501950
if not self.get_visible() or not self._check_xy(renderer):
19511951
return
1952+
# Update text positions before `Text.draw` would, so that the
1953+
# FancyArrowPatch is correctly positioned.
19521954
self.update_positions(renderer)
1955+
self.update_bbox_position_size(renderer)
19531956
if self.arrow_patch is not None: # FancyArrowPatch
19541957
if self.arrow_patch.figure is None and self.figure is not None:
19551958
self.arrow_patch.figure = self.figure

0 commit comments

Comments
 (0)