Implement conditional autoscaling for Collections using Artist autoscale flag#31274
Implement conditional autoscaling for Collections using Artist autoscale flag#31274Archiljain wants to merge 5 commits intomatplotlib:mainfrom
Conversation
lib/matplotlib/axes/_base.py
Outdated
| import matplotlib.text as mtext | ||
| import matplotlib.ticker as mticker | ||
| import matplotlib.transforms as mtransforms | ||
| import matplotlib.collections as mcollections |
There was a problem hiding this comment.
collections is already imported above.
lib/matplotlib/axes/_base.py
Outdated
| def _update_collection_limits(self, collection): | ||
| offsets = collection.get_offsets() | ||
| if offsets is not None and len(offsets): | ||
| self.update_datalim(offsets) |
There was a problem hiding this comment.
Very wrong indent, I don't know why linting isn't complaining.
This method also appears to be inserted into a completely random spot; I'd expect it to be located somewhere that parallels the other _update* methods.
lib/matplotlib/tests/test_axes.py
Outdated
| def test_relim_updates_scatter_offsets(): | ||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
|
|
timhoffm
left a comment
There was a problem hiding this comment.
Please explain in detail what the code change does.
- How does it affect add_collection, is that the behavior we want/is that consistent with other add_* functions now? Should it?
- How does if affect relim?
- Why does `_update_collection_limits need an autolim parameter wheras the other update* methods don't have this.
lib/matplotlib/axes/_base.py
Outdated
| mtransforms.blended_transform_factory( | ||
| self.xaxis.get_transform(), self.yaxis.get_transform())) | ||
|
|
||
| def _update_collection_limits(self, collection, autolim): |
There was a problem hiding this comment.
Why did you put the method in exactly this location?
This needs a docstring.
There was a problem hiding this comment.
okay I have shifted the _update_collection_limits after understanding other update function location .
2.Functionally, 3.This change does not alter the behavior of
|
Fixes conditional autoscaling behavior for Collections by using the
Artist autoscale participation flag introduced in PR1.
Previously, the
autolimparameter inAxes.add_collection()did notfully control whether a Collection participates in autoscaling.
This PR connects the
autolimargument with the Artist autoscaleparticipation mechanism, ensuring that Collections are included or
excluded from autoscaling depending on the provided parameter.
Changes
add_collection(..., autolim=True)excludes the collectionfrom autoscaling
Related to discussion in PR #31128 .
Follow-up to maintainer suggestion by @timhoffm regarding conditional
autoscaling of Collections.