MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / add_collection

Method add_collection

lib/matplotlib/axes/_base.py:2378–2431  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers 15

fill_betweenMethod · 0.80
plot_surfaceMethod · 0.80
plot_wireframeMethod · 0.80
plot_trisurfMethod · 0.80
add_collection3dMethod · 0.80
bar3dMethod · 0.80
quiverMethod · 0.80
errorbarMethod · 0.80
stemMethod · 0.80
_test_proj_draw_axesFunction · 0.80
test_zordered_errorFunction · 0.80

Calls 9

_set_artist_propsMethod · 0.95
_unstale_viewLimMethod · 0.95
_set_in_autoscaleMethod · 0.80
get_labelMethod · 0.45
set_labelMethod · 0.45
get_clip_pathMethod · 0.45
set_clip_pathMethod · 0.45

Tested by 15

_test_proj_draw_axesFunction · 0.64
test_zordered_errorFunction · 0.64
plot_pathsFunction · 0.64
test_path_collectionFunction · 0.64
test_mixed_collectionFunction · 0.64