Skip to content

Commit

Permalink
Merge pull request #5711 from tacaswell/fix_remove_container
Browse files Browse the repository at this point in the history
FIX: Container remove method
  • Loading branch information
mdboom committed Dec 22, 2015
2 parents 227f0c4 + 4604517 commit 5ccc604
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,7 @@ def tk_window_focus():
'matplotlib.tests.test_colorbar',
'matplotlib.tests.test_colors',
'matplotlib.tests.test_compare_images',
'matplotlib.tests.test_container',
'matplotlib.tests.test_contour',
'matplotlib.tests.test_dates',
'matplotlib.tests.test_delaunay',
Expand Down
5 changes: 4 additions & 1 deletion lib/matplotlib/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from matplotlib.externals import six

import matplotlib.cbook as cbook
import matplotlib.artist as martist


class Container(tuple):
Expand Down Expand Up @@ -31,7 +32,9 @@ def set_remove_method(self, f):
self._remove_method = f

def remove(self):
for c in self:
for c in cbook.flatten(self,
scalarp=lambda x: isinstance(x,
martist.Artist)):
c.remove()

if self._remove_method:
Expand Down
14 changes: 14 additions & 0 deletions lib/matplotlib/tests/test_container.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

from matplotlib.externals import six
import matplotlib.pyplot as plt

from matplotlib.testing.decorators import cleanup


@cleanup
def test_stem_remove():
ax = plt.gca()
st = ax.stem([1, 2], [1, 2])
st.remove()

0 comments on commit 5ccc604

Please sign in to comment.