8000 Annotate: draw text before arrow; closes #4140 · matplotlib/matplotlib@896880c · GitHub
[go: up one dir, main page]

Skip to content

Commit 896880c

Browse files
committed
Annotate: draw text before arrow; closes #4140
Some comment and docstring typos are also fixed.
1 parent fb7f90c commit 896880c

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/matplotlib/patches.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2590,14 +2590,14 @@ class ConnectionStyle(_Style):
25902590

25912591
class _Base(object):
25922592
"""
2593-
A base class for connectionstyle classes. The dervided needs
2594-
to implement a *connect* methods whose call signature is::
2593+
A base class for connectionstyle classes. The subclass needs
2594+
to implement a *connect* method whose call signature is::
25952595
259625 10000 96
connect(posA, posB)
25972597
25982598
where posA and posB are tuples of x, y coordinates to be
2599-
connected. The methods needs to return a path connecting two
2600-
points. This base class defines a __call__ method, and few
2599+
connected. The method needs to return a path connecting two
2600+
points. This base class defines a __call__ method, and a few
26012601
helper methods.
26022602
"""
26032603

@@ -2681,7 +2681,7 @@ def __call__(self, posA, posB,
26812681
return shrinked_path
26822682

26832683
def __reduce__(self):
2684-
# because we have decided to nest thes classes, we need to
2684+
# because we have decided to nest these classes, we need to
26852685
# add some more information to allow instance pickling.
26862686
import matplotlib.cbook as cbook
26872687
return (cbook._NestedClassGetter(),
@@ -2926,7 +2926,7 @@ def connect(self, posA, posB):
29262926
class Bar(_Base):
29272927
"""
29282928
A line with *angle* between A and B with *armA* and
2929-
*armB*. One of the arm is extend so that they are connected in
2929+
*armB*. One of the arms is extended so that they are connected in
29302930
a right angle. The length of armA is determined by (*armA*
29312931
+ *fraction* x AB distance). Same for armB.
29322932
"""
@@ -3897,7 +3897,7 @@ def __init__(self, posA=None, posB=None,
38973897
"""
38983898
If *posA* and *posB* is given, a path connecting two point are
38993899
created according to the connectionstyle. The path will be
3900-
clipped with *patchA* and *patchB* and further shirnked by
3900+
clipped with *patchA* and *patchB* and further shrinked by
39013901
*shrinkA* and *shrinkB*. An arrow is drawn along this
39023902
resulting path using the *arrowstyle* parameter. If *path*
39033903
provided, an arrow is drawn along this path and *patchA*,

lib/matplotlib/text.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def update_from(self, other):
296296
def _get_layout(self, renderer):
297297
"""
298298
return the extent (bbox) of the text together with
299-
multile-alignment information. Note that it returns a extent
299+
multiple-alignment information. Note that it returns an extent
300300
of a rotated text when necessary.
301301
"""
302302
key = self.get_prop_tup()
@@ -2063,6 +2063,10 @@ def draw(self, renderer):
20632063
self._update_position_xytext(renderer, xy_pixel)
20642064
self.update_bbox_position_size(renderer)
20652065

2066+
# Draw text, including FancyBboxPatch, before FancyArrowPatch.
2067+
# Otherwise, the transform of the former Patch will be incomplete.
2068+
Text.draw(self, renderer)
2069+
20662070
if self.arrow is not None:
20672071
if self.arrow.figure is None and self.figure is not None:
20682072
self.arrow.figure = self.figure
@@ -2073,8 +2077,6 @@ def draw(self, renderer):
20732077
self.arrow_patch.figure = self.figure
20742078
self.arrow_patch.draw(renderer)
20752079

2076-
Text.draw(self, renderer)
2077-
20782080
def get_window_extent(self, renderer=None):
20792081
'''
20802082
Return a :class:`~matplotlib.transforms.Bbox` object bounding

0 commit comments

Comments
 (0)
0