Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e41f5a1

Browse filesBrowse files
authored
Merge pull request #14746 from anntzer/arrow
Simplify Arrow constructor.
2 parents 7a57959 + 1c5cade commit e41f5a1
Copy full SHA for e41f5a1

File tree

Expand file treeCollapse file tree

1 file changed

+7
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-15
lines changed

‎lib/matplotlib/patches.py

Copy file name to clipboardExpand all lines: lib/matplotlib/patches.py
+7-15Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,21 +1176,13 @@ def __init__(self, x, y, dx, dy, width=1.0, **kwargs):
11761176
Patch that allows independent control of the head and tail
11771177
properties
11781178
"""
1179-
Patch.__init__(self, **kwargs)
1180-
L = np.hypot(dx, dy)
1181-
1182-
if L != 0:
1183-
cx = dx / L
1184-
sx = dy / L
1185-
else:
1186-
# Account for division by zero
1187-
cx, sx = 0, 1
1188-
1189-
trans1 = transforms.Affine2D().scale(L, width)
1190-
trans2 = transforms.Affine2D.from_values(cx, sx, -sx, cx, 0.0, 0.0)
1191-
trans3 = transforms.Affine2D().translate(x, y)
1192-
trans = trans1 + trans2 + trans3
1193-
self._patch_transform = trans.frozen()
1179+
super().__init__(**kwargs)
1180+
self._patch_transform = (
1181+
transforms.Affine2D()
1182+
.scale(np.hypot(dx, dy), width)
1183+
.rotate(np.arctan2(dy, dx))
1184+
.translate(x, y)
1185+
.frozen())
11941186

11951187
def get_path(self):
11961188
return self._path

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.