Skip to content

Store FloatingAxes "extremes" info in fewer places. #25427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations/25427-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
``GridHelperCurveLinear.get_data_boundary``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... is deprecated. Use ``grid_finder.extreme_finder(*[None] * 5)`` to get the
extremes of the grid.
19 changes: 9 additions & 10 deletions lib/mpl_toolkits/axisartist/floating_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def __init__(self, grid_helper, side, nth_coord_ticks=None):
nth_coord = along which coordinate value varies.
nth_coord = 0 -> x axis, nth_coord = 1 -> y axis
"""
value, nth_coord = grid_helper.get_data_boundary(side)
lon1, lon2, lat1, lat2 = grid_helper.grid_finder.extreme_finder(*[None] * 5)
value, nth_coord = _api.check_getitem(
dict(left=(lon1, 0), right=(lon2, 0), bottom=(lat1, 1), top=(lat2, 1)),
side=side)
super().__init__(grid_helper, nth_coord, value, axis_direction=side)
if nth_coord_ticks is None:
nth_coord_ticks = nth_coord
Expand All @@ -58,7 +61,7 @@ def get_tick_iterators(self, axes):
lon_levs, lon_n, lon_factor = self._grid_info["lon_info"]
xx0 = lon_levs / lon_factor

extremes = self.grid_helper._extremes
extremes = self.grid_helper.grid_finder.extreme_finder(*[None] * 5)
xmin, xmax = sorted(extremes[:2])
ymin, ymax = sorted(extremes[2:])

Expand Down Expand Up @@ -137,20 +140,19 @@ def __init__(self, aux_trans, extremes,
tick_formatter1=None,
tick_formatter2=None):
# docstring inherited
self._extremes = extremes
extreme_finder = ExtremeFinderFixed(extremes)
super().__init__(aux_trans,
extreme_finder,
extreme_finder=ExtremeFinderFixed(extremes),
grid_locator1=grid_locator1,
grid_locator2=grid_locator2,
tick_formatter1=tick_formatter1,
tick_formatter2=tick_formatter2)

@_api.deprecated("3.8")
def get_data_boundary(self, side):
"""
Return v=0, nth=1.
"""
lon1, lon2, lat1, lat2 = self._extremes
lon1, lon2, lat1, lat2 = self.grid_finder.extreme_finder(*[None] * 5)
return dict(left=(lon1, 0),
right=(lon2, 0),
bottom=(lat1, 1),
Expand Down Expand Up @@ -262,10 +264,7 @@ def __init__(self, *args, grid_helper, **kwargs):

def _gen_axes_patch(self):
# docstring inherited
# Using a public API to access _extremes.
(x0, _), (x1, _), (y0, _), (y1, _) = map(
self.get_grid_helper().get_data_boundary,
["left", "right", "bottom", "top"])
x0, x1, y0, y1 = self.get_grid_helper().grid_finder.extreme_finder(*[None] * 5)
patch = mpatches.Polygon([(x0, y0), (x1, y0), (x1, y1), (x0, y1)])
patch.get_path()._interpolation_steps = 100
return patch
Expand Down