Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a1c58ec

Browse files
committed
DOC/MNT: Address reviewer feedback on add_collection docstring and autoscale semantics
- Revert autolim docstring first line to original user-facing wording ("update data and view limits" instead of internal "request autoscaling") - Adopt reviewer suggestion for If-False clause: "does not take part in any limit operations" - Expand versionchanged:: 3.11 note to explain both pre-3.11 behavior and the new relim participation (per reviewer suggestion) - Move _set_in_autoscale(True) inside if autolim: block (simpler and consistent with how add_line/add_patch/add_image do it) - Update stale TODO in Artist.remove: the "collections relim problem" referenced has been fixed; rephrase to reflect the remaining long-term architectural goal
1 parent ee070e3 commit a1c58ec

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

lib/matplotlib/artist.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ def remove(self):
268268

269269
else:
270270
raise NotImplementedError('cannot remove artist')
271-
# TODO: the fix for the collections relim problem is to move the
272-
# limits calculation into the artist itself, including the property of
273-
# whether or not the artist should affect the limits. Then there will
274-
# be no distinction between axes.add_line, axes.add_patch, etc.
271+
# TODO: move the limits calculation into the artist itself, including
272+
# the property of whether or not the artist should affect the limits.
273+
# Then there will be no distinction between axes.add_line,
274+
# axes.add_patch, etc.
275275
# TODO: add legend support
276276

277277
def have_units(self):

lib/matplotlib/axes/_base.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,15 +2384,23 @@ def add_collection(self, collection, autolim=True):
23842384
collection : `.Collection`
23852385
The collection to add.
23862386
autolim : bool
2387-
Whether to update data limits and request autoscaling.
2387+
Whether to update data and view limits.
23882388
2389-
If *False*, the collection is explicitly excluded from
2390-
`~.Axes.relim`.
2389+
If *False*, the collection does not take part in any limit
2390+
operations.
23912391
23922392
.. versionchanged:: 3.11
23932393
2394-
This now also updates the view limits, making explicit
2395-
calls to `~.Axes.autoscale_view` unnecessary.
2394+
Since 3.11 `autolim=True` matches the standard behavior
2395+
of other ``add_[artist]`` methods: Axes data and view limits
2396+
are both updated in the method, and the collection will
2397+
be considered in future data limit updates through
2398+
`.relim`.
2399+
2400+
Prior to matplotlib 3.11 this was only a one-time update
2401+
of the data limits. Updating view limits required an
2402+
explicit calls to `~.Axes.autoscale_view`, and collections
2403+
did not take part in `.relim`.
23962404
23972405
As an implementation detail, the value "_datalim_only" is
23982406
supported to smooth the internal transition from pre-3.11
@@ -2409,11 +2417,8 @@ def add_collection(self, collection, autolim=True):
24092417
if collection.get_clip_path() is None:
24102418
collection.set_clip_path(self.patch)
24112419

2412-
# Keep relim() participation aligned with the autolim argument.
2413-
# autolim can also be the internal sentinel "_datalim_only".
2414-
collection._set_in_autoscale(bool(autolim))
2415-
24162420
if autolim:
2421+
collection._set_in_autoscale(True)
24172422
# Make sure viewLim is not stale (mostly to match
24182423
# pre-lazy-autoscale behavior, which is not really better).
24192424
self._unstale_viewLim()

0 commit comments

Comments
 (0)