8000 Merge pull request #17748 from anntzer/unbez · matplotlib/matplotlib@f6ff8db · GitHub
[go: up one dir, main page]

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 f6ff8db

Browse files
authored
Merge pull request #17748 from anntzer/unbez
Don't use bezier helpers in axisartist.
2 parents e73d4e0 + 25fcdbe commit f6ff8db

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lib/mpl_toolkits/axisartist/axisline_style.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import math
2+
3+
import numpy as np
4+
15
from matplotlib.patches import _Style, FancyArrowPatch
26
from matplotlib.transforms import IdentityTransform
37
from matplotlib.path import Path
4-
import numpy as np
58

69

710
class _FancyAxislineStyle:
@@ -37,22 +40,15 @@ def _extend_path(self, path, mutation_size=10):
3740
"""
3841
Extend the path to make a room for drawing arrow.
3942
"""
40-
from matplotlib.bezier import get_cos_sin
41-
42-
x0, y0 = path.vertices[-2]
43-
x1, y1 = path.vertices[-1]
44-
cost, sint = get_cos_sin(x0, y0, x1, y1)
45-
46-
d = mutation_size * 1.
47-
x2, y2 = x1 + cost*d, y1+sint*d
48-
43+
(x0, y0), (x1, y1) = path.vertices[-2:]
44+
theta = math.atan2(y1 - y0, x1 - x0)
45+
x2 = x1 + math.cos(theta) * mutation_size
46+
y2 = y1 + math.sin(theta) * mutation_size
4947
if path.codes is None:
50-
_path = Path(np.concatenate([path.vertices, [[x2, y2]]]))
48+
return Path(np.concatenate([path.vertices, [[x2, y2]]]))
5149
else:
52-
_path = Path(np.concatenate([path.vertices, [[x2, y2]]]),
53-
np.concatenate([path.codes, [Path.LINETO]]))
54-
55-
return _path
50+
return Path(np.concatenate([path.vertices, [[x2, y2]]]),
51+
np.concatenate([path.codes, [Path.LINETO]]))
5652

5753
def set_path(self, path):
5854
self._line_path = path

0 commit comments

Comments
 (0)
0