Add a `.Collection` to the Axes; return the collection. Parameters ---------- collection : `.Collection` The collection to add. autolim : bool Whether to update data and view limits. If *False*, the collection does not ta
(self, collection, autolim=True)
| 2376 | return ax |
| 2377 | |
| 2378 | def add_collection(self, collection, autolim=True): |
| 2379 | """ |
| 2380 | Add a `.Collection` to the Axes; return the collection. |
| 2381 | |
| 2382 | Parameters |
| 2383 | ---------- |
| 2384 | collection : `.Collection` |
| 2385 | The collection to add. |
| 2386 | autolim : bool |
| 2387 | Whether to update data and view limits. |
| 2388 | |
| 2389 | If *False*, the collection does not take part in any limit |
| 2390 | operations. |
| 2391 | |
| 2392 | .. versionchanged:: 3.11 |
| 2393 | |
| 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 call to `~.Axes.autoscale_view`, and collections |
| 2403 | did not take part in `.relim`. |
| 2404 | |
| 2405 | As an implementation detail, the value "_datalim_only" is |
| 2406 | supported to smooth the internal transition from pre-3.11 |
| 2407 | behavior. This is not a public interface and will be removed |
| 2408 | again in the future. |
| 2409 | """ |
| 2410 | _api.check_isinstance(mcoll.Collection, collection=collection) |
| 2411 | if not collection.get_label(): |
| 2412 | collection.set_label(f'_child{len(self._children)}') |
| 2413 | self._children.append(collection) |
| 2414 | collection._remove_method = self._children.remove |
| 2415 | self._set_artist_props(collection) |
| 2416 | |
| 2417 | if collection.get_clip_path() is None: |
| 2418 | collection.set_clip_path(self.patch) |
| 2419 | |
| 2420 | if autolim: |
| 2421 | if autolim != "_datalim_only": |
| 2422 | collection._set_in_autoscale(True) |
| 2423 | # Make sure viewLim is not stale (mostly to match |
| 2424 | # pre-lazy-autoscale behavior, which is not really better). |
| 2425 | self._unstale_viewLim() |
| 2426 | self._update_collection_limits(collection) |
| 2427 | if autolim != "_datalim_only": |
| 2428 | self._request_autoscale_view() |
| 2429 | |
| 2430 | self.stale = True |
| 2431 | return collection |
| 2432 | |
| 2433 | def add_image(self, image): |
| 2434 | """ |