diff --git a/doc/api/next_api_changes/deprecations/19042-AL.rst b/doc/api/next_api_changes/deprecations/19042-AL.rst new file mode 100644 index 000000000000..24061f53fac4 --- /dev/null +++ b/doc/api/next_api_changes/deprecations/19042-AL.rst @@ -0,0 +1,5 @@ +``GridHelperBase`` invalidation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The ``GridHelperBase.invalidate``, ``GridHelperBase.valid``, and +``axislines.Axes.invalidate_grid_helper`` methods are considered internal +and deprecated. diff --git a/lib/mpl_toolkits/axisartist/axislines.py b/lib/mpl_toolkits/axisartist/axislines.py index 1de302c76dc0..05e1d1cd6ce0 100644 --- a/lib/mpl_toolkits/axisartist/axislines.py +++ b/lib/mpl_toolkits/axisartist/axislines.py @@ -315,25 +315,26 @@ def _f(locs, labels): class GridHelperBase: def __init__(self): - self._force_update = True + self._force_update = True # Remove together with invalidate()/valid(). self._old_limits = None super().__init__() def update_lim(self, axes): x1, x2 = axes.get_xlim() y1, y2 = axes.get_ylim() - if self._force_update or self._old_limits != (x1, x2, y1, y2): - self._update(x1, x2, y1, y2) + self._update_grid(x1, y1, x2, y2) self._force_update = False self._old_limits = (x1, x2, y1, y2) - def _update(self, x1, x2, y1, y2): - pass + def _update_grid(self, x1, y1, x2, y2): + """Cache relevant computations when the axes limits have changed.""" + @_api.deprecated("3.4") def invalidate(self): self._force_update = True + @_api.deprecated("3.4") def valid(self): return not self._force_update @@ -555,6 +556,7 @@ def get_children(self): children.extend(super().get_children()) return children + @_api.deprecated("3.4") def invalidate_grid_helper(self): self._grid_helper.invalidate() diff --git a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py index cd8f4ad77aaa..bb67dd0d78c8 100644 --- a/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py +++ b/lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py @@ -289,7 +289,6 @@ def __init__(self, aux_trans, """ super().__init__() self.grid_info = None - self._old_values = None self._aux_trans = aux_trans self.grid_finder = GridFinder(aux_trans, extreme_finder, @@ -302,16 +301,7 @@ def update_grid_finder(self, aux_trans=None, **kw): if aux_trans is not None: self.grid_finder.update_transform(aux_trans) self.grid_finder.update(**kw) - self.invalidate() - - def _update(self, x1, x2, y1, y2): - """bbox in 0-based image coordinates""" - # update wcsgrid - if self.valid() and self._old_values == (x1, x2, y1, y2): - return - self._update_grid(x1, y1, x2, y2) - self._old_values = (x1, x2, y1, y2) - self._force_update = False + self._old_limits = None # Force revalidation. def new_fixed_axis(self, loc, nth_coord=None,