X Tutup
Skip to content

Fix relim() ignoring scatter PathCollection offsets#31128

Merged
ksunden merged 3 commits intomatplotlib:mainfrom
Archiljain:main
Mar 6, 2026
Merged

Fix relim() ignoring scatter PathCollection offsets#31128
ksunden merged 3 commits intomatplotlib:mainfrom
Archiljain:main

Conversation

@Archiljain
Copy link
Copy Markdown
Contributor

@Archiljain Archiljain commented Feb 10, 2026

Fixes issue where ax.relim() does not update limits after scatter
offsets are changed via set_offsets().

Adds handling for Collection artists in Axes.relim() by
updating data limits from collection offsets.

Includes a regression test to verify that axis limits update
correctly after scatter data changes.

Closes #30859

@timhoffm
Copy link
Copy Markdown
Member

timhoffm commented Feb 10, 2026

Adding _update_collection_limits could be a reasonable intermediate step to make handling more consistent. But overall, we likely want to move a way from _update_* methods, see #15595 (comment).

Edit: It may be much more complicated than this. Since we have the option add_collection(..., autolim=False) we must not always update. If a user/function has decided not to update the limits, we must not push updates through the backdoor of relim(). This means the bug cannot be fixed properly without addressing the general set_in_autoscale concept (#15595) - or hacking in a speical solution for collections, which is most likely not the way to go.

@timhoffm
Copy link
Copy Markdown
Member

timhoffm commented Feb 11, 2026

@Archiljain thanks for the contribution so far. As the topic is more involved, we cannot do a standalone solution without tackling a mechanism that makes inclusion of Artists in autoscaling optional.

Following up on my previous note regarding entanglement of Collection limits considered in relim() and optional inclusion in autoscaling, I think the way forward is this:

  1. PR1: Implement a private version of set_in_autoscale()
  2. PR2: Use that version to correctly handle conditional autoscaling of collecitons depending on the autolim paramter in add_collection(..., autolim=...). Thereby fix this topic here, also adding _update_collection_limits()
  3. PR3: Consider rearchitecting limits handling further as discussed in Add set_in_autoscale() method  #15595 (comment). This may include replacing the _update_*_limits() functions by retrieveing limits from the Artists.

@Archiljain
Copy link
Copy Markdown
Contributor Author

Thanks for the clarification.

I'm happy to work on PR1 (implementing the private set_in_autoscale mechanism) as a first step if that helps move this forward. Please let me know if that’s the preferred direction.

@timhoffm
Copy link
Copy Markdown
Member

@Archiljain you are welcome to work on this. Please read the full discussion in #15595 and use for context, in particular #15595 (comment).

Since this is internal for now, naming is not too critical. I would stick to the in_autoscale terminology for now. But we may come up with a better name.

@Archiljain
Copy link
Copy Markdown
Contributor Author

I propose introducing a private Artist-level _in_autoscale flag (mirroring _in_layout), checked centrally in Axes.relim() to gate whether an artist contributes to data limits. No behavior change yet.

@Archiljain
Copy link
Copy Markdown
Contributor Author

Thanks for the guidance. I see that this needs a more foundational change.
I’ll put together a separate PR for the private Artist-level autoscale flag (PR1), and then rework this PR on top of that as PR2.

@melissawm melissawm moved this to Waiting for author in First Time Contributors Mar 6, 2026
@ksunden ksunden merged commit fbb623e into matplotlib:main Mar 6, 2026
40 of 46 checks passed
@github-project-automation github-project-automation bot moved this from Waiting for author to Merged in First Time Contributors Mar 6, 2026
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Mar 7, 2026

This should be re-done in a new PR; #31166 contained these commits so GitHub marked it as merged, but it also reverted all these changes, so they haven't actually landed in main.

@Archiljain
Copy link
Copy Markdown
Contributor Author

I'm planning to apply for GSoC this year and would love to continue contributing to autoscaling improvements. Are there related issues where help would be valuable?

tonybaloney pushed a commit to tonybaloney/swe-complex-matplotlib that referenced this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[Bug]: ax.relim() ignores scatter artist

5 participants

X Tutup