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

Skip to content

Commit 48c7360

Browse files
committed
Drop None from Container.get_children().
Before the patch, ``` ec = plt.errorbar([1, 2], [3, 4], [5, 6], capsize=2, fmt="none") print(ec.get_children()) ``` would print `None` (corresponding to the "not drawn" line connecting the data points), two `Line2D` and one `LineCollection`. This patch drops the `None` out, as it is arguably not a child of the Container. (It is still possible to access the individual members of the Container by unpacking it as a tuple.) Also reformat an overly indented piece of code in the vicinity.
1 parent 2bce760 commit 48c7360

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/matplotlib/container.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ def set_remove_method(self, f):
3232
self._remove_method = f
3333

3434
def remove(self):
35-
for c in cbook.flatten(self,
36-
scalarp=lambda x: isinstance(x,
37-
martist.Artist)):
35+
for c in cbook.flatten(
36+
self, scalarp=lambda x: isinstance(x, martist.Artist)):
3837
c.remove()
3938

4039
if self._remove_method:
@@ -102,7 +101,7 @@ def pchanged(self):
102101
func(self)
103102

104103
def get_children(self):
105-
return list(cbook.flatten(self))
104+
return [child for child in cbook.flatten(self) if child is not None]
106105

107106

108107
class BarContainer(Container):

0 commit comments

Comments
 (0)