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

Skip to content

Commit 4604517

Browse files
committed
FIX: Container remove method
It was not properly looping over sub-children of the container. closes #5692
1 parent 227f0c4 commit 4604517

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/matplotlib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ def tk_window_focus():
14401440
'matplotlib.tests.test_colorbar',
14411441
'matplotlib.tests.test_colors',
14421442
'matplotlib.tests.test_compare_images',
1443+
'matplotlib.tests.test_container',
14431444
'matplotlib.tests.test_contour',
14441445
'matplotlib.tests.test_dates',
14451446
'matplotlib.tests.test_delaunay',

lib/matplotlib/container.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from matplotlib.externals import six
55

66
import matplotlib.cbook as cbook
7+
import matplotlib.artist as martist
78

89

910
class Container(tuple):
@@ -31,7 +32,9 @@ def set_remove_method(self, f):
3132
self._remove_method = f
3233

3334
def remove(self):
34-
for c in self:
35+
for c in cbook.flatten(self,
36+
scalarp=lambda x: isinstance(x,
37+
martist.Artist)):
3538
c.remove()
3639

3740
if self._remove_method:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import (absolute_import, division, print_function,
2+
unicode_literals)
3+
4+
from matplotlib.externals import six
5+
import matplotlib.pyplot as plt
6+
7+
from matplotlib.testing.decorators import cleanup
8+
9+
10+
@cleanup
11+
def test_stem_remove():
12+
ax = plt.gca()
13+
st = ax.stem([1, 2], [1, 2])
14+
st.remove()

0 commit comments

Comments
 (0)