|
11 | 11 | import numpy as np
|
12 | 12 |
|
13 | 13 | import matplotlib as mpl
|
| 14 | +import matplotlib.artist as martist |
| 15 | +import matplotlib.axis as maxis |
14 | 16 | from matplotlib import cbook
|
15 | 17 | from matplotlib.cbook import _OrderedSet, _check_1d, index_of
|
16 |
| -from matplotlib import docstring |
| 18 | +import matplotlib.collections as mcoll |
17 | 19 | import matplotlib.colors as mcolors
|
| 20 | +from matplotlib import docstring |
| 21 | +import matplotlib.font_manager as font_manager |
| 22 | +import matplotlib.image as mimage |
18 | 23 | import matplotlib.lines as mlines
|
19 | 24 | import matplotlib.patches as mpatches
|
20 |
| -import matplotlib.artist as martist |
21 |
| -import matplotlib.transforms as mtransforms |
22 |
| -import matplotlib.ticker as mticker |
23 |
| -import matplotlib.axis as maxis |
| 25 | +from matplotlib.rcsetup import cycler, validate_axisbelow |
24 | 26 | import matplotlib.spines as mspines
|
25 |
| -import matplotlib.font_manager as font_manager |
26 | 27 | import matplotlib.table as mtable
|
27 | 28 | import matplotlib.text as mtext
|
28 |
| -import matplotlib.image as mimage |
29 |
| -from matplotlib.rcsetup import cycler, validate_axisbelow |
| 29 | +import matplotlib.ticker as mticker |
| 30 | +import matplotlib.transforms as mtransforms |
30 | 31 |
|
31 | 32 | _log = logging.getLogger(__name__)
|
32 | 33 |
|
@@ -1110,7 +1111,6 @@ def cla(self):
|
1110 | 1111 | self.child_axes = []
|
1111 | 1112 | self._current_image = None # strictly for pyplot via _sci, _gci
|
1112 | 1113 | self.legend_ = None
|
1113 |
| - self.collections = [] # collection.Collection instances |
1114 | 1114 | self.containers = []
|
1115 | 1115 |
|
1116 | 1116 | self.grid(False) # Disable grid on init to use rcParameter
|
@@ -1178,6 +1178,11 @@ def cla(self):
|
1178 | 1178 |
|
1179 | 1179 | self.stale = True
|
1180 | 1180 |
|
| 1181 | + @property |
| 1182 | + def collections(self): |
| 1183 | + return tuple(a for a in self._children |
| 1184 | + if isinstance(a, mcoll.Collection)) |
| 1185 | + |
1181 | 1186 | @property
|
1182 | 1187 | def images(self):
|
1183 | 1188 | return tuple(a for a in self._children
|
@@ -1948,13 +1953,13 @@ def add_child_axes(self, ax):
|
1948 | 1953 |
|
1949 | 1954 | def add_collection(self, collection, autolim=True):
|
1950 | 1955 | """
|
1951 |
| - Add a `~.Collection` to the axes' collections; return the collection. |
| 1956 | + Add a `~.Collection` to the Axes; return the collection. |
1952 | 1957 | """
|
1953 | 1958 | label = collection.get_label()
|
1954 | 1959 | if not label:
|
1955 |
| - collection.set_label('_collection%d' % len(self.collections)) |
1956 |
| - self.collections.append(collection) |
1957 |
| - collection._remove_method = self.collections.remove |
| 1960 | + collection.set_label(f'_collection{len(self._children)}') |
| 1961 | + self._children.append(collection) |
| 1962 | + collection._remove_method = self._children.remove |
1958 | 1963 | self._set_artist_props(collection)
|
1959 | 1964 |
|
1960 | 1965 | if collection.get_clip_path() is None:
|
@@ -4077,7 +4082,6 @@ def format_deltas(key, dx, dy):
|
4077 | 4082 | def get_children(self):
|
4078 | 4083 | # docstring inherited.
|
4079 | 4084 | return [
|
4080 |
| - *self.collections, |
4081 | 4085 | *self._children,
|
4082 | 4086 | *self.artists,
|
4083 | 4087 | *self.spines.values(),
|
|
0 commit comments