matplotlib / matplotlib/matplotlib
[ENH]: generalize artists opting in-to auto limits
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 23.2k
- Forks
- 8.5k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 66
Description
### Problem
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 https://github.com/matplotlib/matplotlib/blob/a046ee3febac399869c3eb6b15b8e669e37058ee/lib/matplotlib/axes/_base.py#L2459-L2483 and collections may optionally participate, but only when they are added https://github.com/matplotlib/matplotlib/blob/a046ee3febac399869c3eb6b15b8e669e37058ee/lib/matplotlib/axes/_base.py#L2260-L2273
### 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).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/matplotlib/axes/_base.py at the linked _update_line_limits code and the collection handling, then inspect the Artist base class and relim. Define how artists opt into autolimiting, where the existing update methods belong, and the public and private API signatures. Done means Lines, Patches, AxesImage, and optionally participating collections use the generalized behavior without breaking relim.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100