From dd00bdee2ae211266818adca85d4071fe4d15719 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 7 Nov 2023 09:17:58 +0100 Subject: [PATCH] Remove idiosyncratic get_tick_iterator API. It's only ever used essentially to expose GridHelperCurveLinear._grid_info to FixedAxisArtistHelper.get_tick_iterators; it seems better to access it from the sole caller. (Note that floating_axes already does the same direct access to the private _grid_info.) Removing get_tick_iterator also removes the confusion with get_tick_iterators (plural), which is a common API in axisartist. Also note that the "minor" parameter of get_tick_iterator had a rather peculiar meaning (it only switched the labels off). --- .../deprecations/27300-AL.rst | 3 +++ .../axisartist/grid_helper_curvelinear.py | 22 +++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/27300-AL.rst diff --git a/doc/api/next_api_changes/deprecations/27300-AL.rst b/doc/api/next_api_changes/deprecations/27300-AL.rst new file mode 100644 index 000000000000..87f4bb259537 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/27300-AL.rst @@ -0,0 +1,3 @@ +``GridHelperCurveLinear.get_tick_iterator`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +... is deprecated with no replacement. diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index 08031122c03b..8dbfa6adf90f 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -3,7 +3,6 @@ """ import functools -from itertools import chain import numpy as np @@ -76,10 +75,18 @@ def get_tick_iterators(self, axes): "top": "bottom", "bottom": "top"}[self.side] else: side = self.side - g = self.grid_helper - ti1 = g.get_tick_iterator(self.nth_coord_ticks, side) - ti2 = g.get_tick_iterator(1-self.nth_coord_ticks, side, minor=True) - return chain(ti1, ti2), iter([]) + + angle_tangent = dict(left=90, right=90, bottom=0, top=0)[side] + + def iter_major(): + for nth_coord, show_labels in [ + (self.nth_coord_ticks, True), (1 - self.nth_coord_ticks, False)]: + gi = self.grid_helper._grid_info[["lon", "lat"][nth_coord]] + for (xy, angle_normal), l in zip( + gi["tick_locs"][side], gi["tick_labels"][side]): + yield xy, angle_normal, angle_tangent, (l if show_labels else "") + + return iter_major(), iter([]) class FloatingAxisArtistHelper(_FloatingAxisArtistHelperBase): @@ -211,14 +218,14 @@ def trf_xy(x, y): in_01 = functools.partial( mpl.transforms._interval_contains_close, (0, 1)) - def f1(): + def iter_major(): for x, y, normal, tangent, lab \ in zip(xx1, yy1, angle_normal, angle_tangent, labels): c2 = tick_to_axes.transform((x, y)) if in_01(c2[0]) and in_01(c2[1]): yield [x, y], *np.rad2deg([normal, tangent]), lab - return f1(), iter([]) + return iter_major(), iter([]) def get_line_transform(self, axes): return axes.transData @@ -309,6 +316,7 @@ def get_gridlines(self, which="major", axis="both"): grid_lines.extend(gl) return grid_lines + @_api.deprecated("3.9") def get_tick_iterator(self, nth_coord, axis_side, minor=False): angle_tangent = dict(left=90, right=90, bottom=0, top=0)[axis_side] lon_or_lat = ["lon", "lat"][nth_coord] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy