|
| 1 | +import math |
| 2 | + |
| 3 | +import numpy as np |
| 4 | + |
1 | 5 | from matplotlib.patches import _Style, FancyArrowPatch |
2 | 6 | from matplotlib.transforms import IdentityTransform |
3 | 7 | from matplotlib.path import Path |
4 | | -import numpy as np |
5 | 8 |
|
6 | 9 |
|
7 | 10 | class _FancyAxislineStyle: |
@@ -37,22 +40,15 @@ def _extend_path(self, path, mutation_size=10): |
37 | 40 | """ |
38 | 41 | Extend the path to make a room for drawing arrow. |
39 | 42 | """ |
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 |
49 | 47 | if path.codes is None: |
50 | | - _path = Path(np.concatenate([path.vertices, [[x2, y2]]])) |
| 48 | + return Path(np.concatenate([path.vertices, [[x2, y2]]])) |
51 | 49 | 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]])) |
56 | 52 |
|
57 | 53 | def set_path(self, path): |
58 | 54 | self._line_path = path |
|
0 commit comments