@@ -586,12 +586,6 @@ def __getstate__(self):
586586
587587 def __setstate__ (self , state ):
588588 self .__dict__ = state
589- # put the _remove_method back on all artists contained within the axes
590- for container_name in ['lines' , 'collections' , 'tables' , 'patches' ,
591- 'texts' , 'images' ]:
592- container = getattr (self , container_name )
593- for artist in container :
594- artist ._remove_method = container .remove
595589 self ._stale = True
596590 self ._layoutbox = None
597591 self ._poslayoutbox = None
@@ -1858,9 +1852,9 @@ def add_artist(self, a):
18581852 """
18591853 a .axes = self
18601854 self .artists .append (a )
1855+ a ._remove_method = self .artists .remove
18611856 self ._set_artist_props (a )
18621857 a .set_clip_path (self .patch )
1863- a ._remove_method = lambda h : self .artists .remove (h )
18641858 self .stale = True
18651859 return a
18661860
@@ -1875,6 +1869,7 @@ def add_collection(self, collection, autolim=True):
18751869 if not label :
18761870 collection .set_label ('_collection%d' % len (self .collections ))
18771871 self .collections .append (collection )
1872+ collection ._remove_method = self .collections .remove
18781873 self ._set_artist_props (collection )
18791874
18801875 if collection .get_clip_path () is None :
@@ -1883,7 +1878,6 @@ def add_collection(self, collection, autolim=True):
18831878 if autolim :
18841879 self .update_datalim (collection .get_datalim (self .transData ))
18851880
1886- collection ._remove_method = lambda h : self .collections .remove (h )
18871881 self .stale = True
18881882 return collection
18891883
@@ -1897,7 +1891,7 @@ def add_image(self, image):
18971891 if not image .get_label ():
18981892 image .set_label ('_image%d' % len (self .images ))
18991893 self .images .append (image )
1900- image ._remove_method = lambda h : self .images .remove ( h )
1894+ image ._remove_method = self .images .remove
19011895 self .stale = True
19021896 return image
19031897
@@ -1920,7 +1914,7 @@ def add_line(self, line):
19201914 if not line .get_label ():
19211915 line .set_label ('_line%d' % len (self .lines ))
19221916 self .lines .append (line )
1923- line ._remove_method = lambda h : self .lines .remove ( h )
1917+ line ._remove_method = self .lines .remove
19241918 self .stale = True
19251919 return line
19261920
@@ -1930,7 +1924,7 @@ def _add_text(self, txt):
19301924 """
19311925 self ._set_artist_props (txt )
19321926 self .texts .append (txt )
1933- txt ._remove_method = lambda h : self .texts .remove ( h )
1927+ txt ._remove_method = self .texts .remove
19341928 self .stale = True
19351929 return txt
19361930
@@ -1993,7 +1987,7 @@ def add_patch(self, p):
19931987 p .set_clip_path (self .patch )
19941988 self ._update_patch_limits (p )
19951989 self .patches .append (p )
1996- p ._remove_method = lambda h : self .patches .remove ( h )
1990+ p ._remove_method = self .patches .remove
19971991 return p
19981992
19991993 def _update_patch_limits (self , patch ):
@@ -2039,7 +2033,7 @@ def add_table(self, tab):
20392033 self ._set_artist_props (tab )
20402034 self .tables .append (tab )
20412035 tab .set_clip_path (self .patch )
2042- tab ._remove_method = lambda h : self .tables .remove ( h )
2036+ tab ._remove_method = self .tables .remove
20432037 return tab
20442038
20452039 def add_container (self , container ):
@@ -2053,7 +2047,7 @@ def add_container(self, container):
20532047 if not label :
20542048 container .set_label ('_container%d' % len (self .containers ))
20552049 self .containers .append (container )
2056- container .set_remove_method ( lambda h : self .containers .remove ( h ))
2050+ container ._remove_method = self .containers .remove
20572051 return container
20582052
20592053 def _on_units_changed (self , scalex = False , scaley = False ):
0 commit comments