From 9470370baa7bfa4de0c7fce498fbdc3652637d59 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Wed, 10 Apr 2024 10:56:49 +0200 Subject: [PATCH] Switch get_grid_info to take a single Bbox as parameter. --- .../next_api_changes/deprecations/30368-AL.rst | 3 +++ lib/mpl_toolkits/axisartist/grid_finder.py | 18 ++++++++++++++---- .../axisartist/grid_helper_curvelinear.py | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 doc/api/next_api_changes/deprecations/30368-AL.rst diff --git a/doc/api/next_api_changes/deprecations/30368-AL.rst b/doc/api/next_api_changes/deprecations/30368-AL.rst new file mode 100644 index 000000000000..efd3c8360ef3 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/30368-AL.rst @@ -0,0 +1,3 @@ +``GridFinder.get_grid_info`` now takes a single bbox as parameter +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Passing ``x1, y1, x2, y2`` as separate parameters is deprecated. diff --git a/lib/mpl_toolkits/axisartist/grid_finder.py b/lib/mpl_toolkits/axisartist/grid_finder.py index e51d4912c732..b984c18cab6c 100644 --- a/lib/mpl_toolkits/axisartist/grid_finder.py +++ b/lib/mpl_toolkits/axisartist/grid_finder.py @@ -169,13 +169,23 @@ def _format_ticks(self, idx, direction, factor, levels): return (fmt.format_ticks(levels) if isinstance(fmt, mticker.Formatter) else fmt(direction, factor, levels)) - def get_grid_info(self, x1, y1, x2, y2): + def get_grid_info(self, *args, **kwargs): """ - lon_values, lat_values : list of grid values. if integer is given, - rough number of grids in each direction. + Compute positioning information for grid lines and ticks, given the + axes' data *bbox*. """ + params = _api.select_matching_signature( + [lambda x1, y1, x2, y2: locals(), lambda bbox: locals()], *args, **kwargs) + if "x1" in params: + _api.warn_deprecated("3.11", message=( + "Passing extents as separate arguments to get_grid_info is deprecated " + "since %(since)s and support will be removed %(removal)s; pass a " + "single bbox instead.")) + bbox = Bbox.from_extents( + params["x1"], params["y1"], params["x2"], params["y2"]) + else: + bbox = params["bbox"] - bbox = Bbox.from_extents(x1, y1, x2, y2) tbbox = self.extreme_finder._find_transformed_bbox( self.get_transform().inverted(), bbox) diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index 1e27b3f571f3..aa37a3680fa5 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -341,7 +341,7 @@ def new_floating_axis(self, nth_coord, value, axes=None, axis_direction="bottom" return axisline def _update_grid(self, bbox): - self._grid_info = self.grid_finder.get_grid_info(*bbox.extents) + self._grid_info = self.grid_finder.get_grid_info(bbox) def get_gridlines(self, which="major", axis="both"): grid_lines = [] 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