|
11 | 11 | from matplotlib.transforms import Affine2D, IdentityTransform
|
12 | 12 | import numpy as np
|
13 | 13 |
|
| 14 | +from matplotlib.path import Path |
| 15 | + |
14 | 16 | class FixedAxisArtistHelper(AxisArtistHelper.Fixed):
|
15 | 17 | """
|
16 | 18 | Helper class for a fixed axis.
|
@@ -76,6 +78,8 @@ def __init__(self, grid_helper, nth_coord, value, axis_direction=None):
|
76 | 78 | self.grid_helper = grid_helper
|
77 | 79 | self._extremes = None, None
|
78 | 80 |
|
| 81 | + self._get_line_path = None # a method that returns a Path. |
| 82 | + self._line_num_points = 100 # number of points to create a line |
79 | 83 |
|
80 | 84 | def set_extremes(self, e1, e2):
|
81 | 85 | self._extremes = e1, e2
|
@@ -125,12 +129,12 @@ def update_lim(self, axes):
|
125 | 129 |
|
126 | 130 | #e1, e2 = self._extremes # ranges of other coordinates
|
127 | 131 | if self.nth_coord == 0:
|
128 |
| - xx0 = np.linspace(self.value, self.value, 100) |
129 |
| - yy0 = np.linspace(extremes[2], extremes[3], 100) |
| 132 | + xx0 = np.linspace(self.value, self.value, self._line_num_points) |
| 133 | + yy0 = np.linspace(extremes[2], extremes[3], self._line_num_points) |
130 | 134 | xx, yy = grid_finder.transform_xy(xx0, yy0)
|
131 | 135 | elif self.nth_coord == 1:
|
132 |
| - xx0 = np.linspace(extremes[0], extremes[1], 100) |
133 |
| - yy0 = np.linspace(self.value, self.value, 100) |
| 136 | + xx0 = np.linspace(extremes[0], extremes[1], self._line_num_points) |
| 137 | + yy0 = np.linspace(self.value, self.value, self._line_num_points) |
134 | 138 | xx, yy = grid_finder.transform_xy(xx0, yy0)
|
135 | 139 |
|
136 | 140 | grid_info["line_xy"] = xx, yy
|
@@ -285,10 +289,12 @@ def get_line_transform(self, axes):
|
285 | 289 |
|
286 | 290 | def get_line(self, axes):
|
287 | 291 | self.update_lim(axes)
|
288 |
| - from matplotlib.path import Path |
289 |
| - xx, yy = self.grid_info["line_xy"] |
| 292 | + x, y = self.grid_info["line_xy"] |
290 | 293 |
|
291 |
| - return Path(zip(xx, yy)) |
| 294 | + if self._get_line_path is None: |
| 295 | + return Path(zip(x, y)) |
| 296 | + else: |
| 297 | + return self._get_line_path(axes, x, y) |
292 | 298 |
|
293 | 299 |
|
294 | 300 |
|
|
0 commit comments