|
3 | 3 | """ |
4 | 4 |
|
5 | 5 | import functools |
6 | | -from itertools import chain |
7 | 6 |
|
8 | 7 | import numpy as np |
9 | 8 |
|
@@ -76,10 +75,18 @@ def get_tick_iterators(self, axes): |
76 | 75 | "top": "bottom", "bottom": "top"}[self.side] |
77 | 76 | else: |
78 | 77 | side = self.side |
79 | | - g = self.grid_helper |
80 | | - ti1 = g.get_tick_iterator(self.nth_coord_ticks, side) |
81 | | - ti2 = g.get_tick_iterator(1-self.nth_coord_ticks, side, minor=True) |
82 | | - return chain(ti1, ti2), iter([]) |
| 78 | + |
| 79 | + angle_tangent = dict(left=90, right=90, bottom=0, top=0)[side] |
| 80 | + |
| 81 | + def iter_major(): |
| 82 | + for nth_coord, show_labels in [ |
| 83 | + (self.nth_coord_ticks, True), (1 - self.nth_coord_ticks, False)]: |
| 84 | + gi = self.grid_helper._grid_info[["lon", "lat"][nth_coord]] |
| 85 | + for (xy, angle_normal), l in zip( |
| 86 | + gi["tick_locs"][side], gi["tick_labels"][side]): |
| 87 | + yield xy, angle_normal, angle_tangent, (l if show_labels else "") |
| 88 | + |
| 89 | + return iter_major(), iter([]) |
83 | 90 |
|
84 | 91 |
|
85 | 92 | class FloatingAxisArtistHelper(_FloatingAxisArtistHelperBase): |
@@ -211,14 +218,14 @@ def trf_xy(x, y): |
211 | 218 | in_01 = functools.partial( |
212 | 219 | mpl.transforms._interval_contains_close, (0, 1)) |
213 | 220 |
|
214 | | - def f1(): |
| 221 | + def iter_major(): |
215 | 222 | for x, y, normal, tangent, lab \ |
216 | 223 | in zip(xx1, yy1, angle_normal, angle_tangent, labels): |
217 | 224 | c2 = tick_to_axes.transform((x, y)) |
218 | 225 | if in_01(c2[0]) and in_01(c2[1]): |
219 | 226 | yield [x, y], *np.rad2deg([normal, tangent]), lab |
220 | 227 |
|
221 | | - return f1(), iter([]) |
| 228 | + return iter_major(), iter([]) |
222 | 229 |
|
223 | 230 | def get_line_transform(self, axes): |
224 | 231 | return axes.transData |
@@ -309,6 +316,7 @@ def get_gridlines(self, which="major", axis="both"): |
309 | 316 | grid_lines.extend(gl) |
310 | 317 | return grid_lines |
311 | 318 |
|
| 319 | + @_api.deprecated("3.9") |
312 | 320 | def get_tick_iterator(self, nth_coord, axis_side, minor=False): |
313 | 321 | angle_tangent = dict(left=90, right=90, bottom=0, top=0)[axis_side] |
314 | 322 | lon_or_lat = ["lon", "lat"][nth_coord] |
|
0 commit comments