@@ -586,12 +586,6 @@ def __getstate__(self):
586
586
587
587
def __setstate__ (self , state ):
588
588
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
595
589
self ._stale = True
596
590
self ._layoutbox = None
597
591
self ._poslayoutbox = None
@@ -1858,9 +1852,9 @@ def add_artist(self, a):
1858
1852
"""
1859
1853
a .axes = self
1860
1854
self .artists .append (a )
1855
+ a ._remove_method = self .artists .remove
1861
1856
self ._set_artist_props (a )
1862
1857
a .set_clip_path (self .patch )
1863
- a ._remove_method = lambda h : self .artists .remove (h )
1864
1858
self .stale = True
1865
1859
return a
1866
1860
@@ -1875,6 +1869,7 @@ def add_collection(self, collection, autolim=True):
1875
1869
if not label :
1876
1870
collection .set_label ('_collection%d' % len (self .collections ))
1877
1871
self .collections .append (collection )
1872
+ collection ._remove_method = self .collections .remove
1878
1873
self ._set_artist_props (collection )
1879
1874
1880
1875
if collection .get_clip_path () is None :
@@ -1883,7 +1878,6 @@ def add_collection(self, collection, autolim=True):
1883
1878
if autolim :
1884
1879
self .update_datalim (collection .get_datalim (self .transData ))
1885
1880
1886
- collection ._remove_method = lambda h : self .collections .remove (h )
1887
1881
self .stale = True
1888
1882
return collection
1889
1883
@@ -1897,7 +1891,7 @@ def add_image(self, image):
1897
1891
if not image .get_label ():
1898
1892
image .set_label ('_image%d' % len (self .images ))
1899
1893
self .images .append (image )
1900
- image ._remove_method = lambda h : self .images .remove ( h )
1894
+ image ._remove_method = self .images .remove
1901
1895
self .stale = True
1902
1896
return image
1903
1897
@@ -1920,7 +1914,7 @@ def add_line(self, line):
1920
1914
if not line .get_label ():
1921
1915
line .set_label ('_line%d' % len (self .lines ))
1922
1916
self .lines .append (line )
1923
- line ._remove_method = lambda h : self .lines .remove ( h )
1917
+ line ._remove_method = self .lines .remove
1924
1918
self .stale = True
1925
1919
return line
1926
1920
@@ -1930,7 +1924,7 @@ def _add_text(self, txt):
1930
1924
"""
1931
1925
self ._set_artist_props (txt )
1932
1926
self .texts .append (txt )
1933
- txt ._remove_method = lambda h : self .texts .remove ( h )
1927
+ txt ._remove_method = self .texts .remove
1934
1928
self .stale = True
1935
1929
return txt
1936
1930
@@ -1993,7 +1987,7 @@ def add_patch(self, p):
1993
1987
p .set_clip_path (self .patch )
1994
1988
self ._update_patch_limits (p )
1995
1989
self .patches .append (p )
1996
- p ._remove_method = lambda h : self .patches .remove ( h )
1990
+ p ._remove_method = self .patches .remove
1997
1991
return p
1998
1992
1999
1993
def _update_patch_limits (self , patch ):
@@ -2039,7 +2033,7 @@ def add_table(self, tab):
2039
2033
self ._set_artist_props (tab )
2040
2034
self .tables .append (tab )
2041
2035
tab .set_clip_path (self .patch )
2042
- tab ._remove_method = lambda h : self .tables .remove ( h )
2036
+ tab ._remove_method = self .tables .remove
2043
2037
return tab
2044
2038
2045
2039
def add_container (self , container ):
@@ -2053,7 +2047,7 @@ def add_container(self, container):
2053
2047
if not label :
2054
2048
container .set_label ('_container%d' % len (self .containers ))
2055
2049
self .containers .append (container )
2056
- container .set_remove_method ( lambda h : self .containers .remove ( h ))
2050
+ container ._remove_method = self .containers .remove
2057
2051
return container
2058
2052
2059
2053
def _on_units_changed (self , scalex = False , scaley = False ):
0 commit comments