This is triggered by #25127 most recently, but this is a discussion we have had a couple of times.
The core of the problem is that users have different expectations about what things will automatically adjust the axes limits (or not) in autolim mode. Currently Lines, Patches and AxesImage obligatorily participate
# pre-lazy-autoscale behavior, which is not really better).
self._unstale_viewLim()
datalim=collection.get_datalim(self.transData)
points=datalim.get_points()
ifnotnp.isinf(datalim.minpos).all():
# By definition, if minpos (minimum positive value) is set
# (i.e., non-inf), then min(points) <= minpos <= max(points),
# and minpos would be superfluous. However, we add minpos to
# the call so that self.dataLim will update its own minpos.
# This ensures that log scales see the correct minimum.
points=np.concatenate([points, [datalim.minpos]])
self.update_datalim(points)
Proposed solution
The proposed solution is to:
move the _update_line_limits and friends to the respective Artists
add an analogous method to the base Artist (probably defaulting to failure)
add a "I would like to particpate in autolimiting!" flag to base Artist
in relim look at the flag and call the newly generalized method above on any artists that opt-in
This will involved a little bit of public API (how to set the state to opt-in) and a bunch of private API (what should the signature of the method be).
Activity
jklymak commented on Feb 2, 2023
A major difficulty is that many of our Artists may be anchored in data co-ordinates, but their bounding boxes are not in data-coordinates.
tacaswell commented on Feb 2, 2023
True, but now we can stuff that complexity back to the Artist classes where we have the best chance of knowing how to actually resolve that problem.
anntzer commented on Feb 2, 2023
See #15595, which I had tried to push for during a sprint.
tacaswell commented on Feb 2, 2023
oh, nice that even has some good discussion over the tricky parts of the API (that I participated in and have no memory of 😞 )!