@@ -354,13 +354,12 @@ def __init__(self,
354
354
self ._dpi = dpi
355
355
self .bbox = TransformedBbox (self .bbox_inches , self .dpi_scale_trans )
356
356
357
- self .frameon = frameon
358
-
359
357
self .transFigure = BboxTransformTo (self .bbox )
360
358
361
359
self .patch = Rectangle (
362
360
xy = (0 , 0 ), width = 1 , height = 1 ,
363
- facecolor = facecolor , edgecolor = edgecolor , linewidth = linewidth )
361
+ facecolor = facecolor , edgecolor = edgecolor , linewidth = linewidth ,
362
+ visible = frameon )
364
363
self ._set_artist_props (self .patch )
365
364
self .patch .set_antialiased (False )
366
365
@@ -643,15 +642,14 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None):
643
642
644
643
def get_children (self ):
645
644
"""Get a list of artists contained in the figure."""
646
- children = [self .patch ]
647
- children .extend (self .artists )
648
- children .extend (self .axes )
649
- children .extend (self .lines )
650
- children .extend (self .patches )
651
- children .extend (self .texts )
652
- children .extend (self .images )
653
- children .extend (self .legends )
654
- return children
645
+ return [self .patch ,
646
+ * self .artists ,
647
+ * self .axes ,
648
+ * self .lines ,
649
+ * self .patches ,
650
+ * self .texts ,
651
+ * self .images ,
652
+ * self .legends ]
655
653
656
654
def contains (self , mouseevent ):
657
655
"""
@@ -940,9 +938,10 @@ def get_dpi(self):
940
938
"""Return the resolution in dots per inch as a float."""
941
939
return self .dpi
942
940
941
+ @cbook .deprecated ("3.1" , alternative = "figure.patch.get_visible" )
943
942
def get_frameon (self ):
944
943
"""Return whether the figure frame will be drawn."""
945
- return self .frameon
944
+ return self .patch . get_visible ()
946
945
947
946
def set_edgecolor (self , color ):
948
947
"""
@@ -997,6 +996,7 @@ def set_figheight(self, val, forward=True):
997
996
"""
998
997
self .set_size_inches (self .get_figwidth (), val , forward = forward )
999
998
999
+ @cbook .deprecated ("3.1" , alternative = "figure.patch.set_visible" )
1000
1000
def set_frameon (self , b ):
1001
1001
"""
1002
1002
Set whether the figure frame (background) is displayed or invisible.
@@ -1005,9 +1005,11 @@ def set_frameon(self, b):
1005
1005
----------
1006
1006
b : bool
1007
1007
"""
1008
- self .frameon = b
1008
+ self .patch . set_visible ( b )
1009
1009
self .stale = True
1010
1010
1011
+ frameon = property (get_frameon , set_frameon )
1012
+
1011
1013
def delaxes (self , ax ):
1012
1014
"""
1013
1015
Remove the `~matplotlib.axes.Axes` *ax* from the figure and update the
@@ -1626,11 +1628,10 @@ def draw(self, renderer):
1626
1628
if not self .get_visible ():
1627
1629
return
1628
1630
1631
+ artists = self .get_children ()
1632
+ artists .remove (self .patch )
1629
1633
artists = sorted (
1630
- (artist for artist in (self .patches + self .lines + self .artists
1631
- + self .images + self .axes + self .texts
1632
- + self .legends )
1633
- if not artist .get_animated ()),
1634
+ (artist for artist in artists if not artist .get_animated ()),
1634
1635
key = lambda artist : artist .get_zorder ())
1635
1636
1636
1637
try :
@@ -1645,9 +1646,7 @@ def draw(self, renderer):
1645
1646
pass
1646
1647
# ValueError can occur when resizing a window.
1647
1648
1648
- if self .frameon :
1649
- self .patch .draw (renderer )
1650
-
1649
+ self .patch .draw (renderer )
1651
1650
mimage ._draw_list_compositing_images (
1652
1651
renderer , self , artists , self .suppressComposite )
1653
1652
@@ -2107,13 +2106,13 @@ def savefig(self, fname, *, frameon=None, transparent=None, **kwargs):
2107
2106
kwargs .setdefault ('edgecolor' , rcParams ['savefig.edgecolor' ])
2108
2107
2109
2108
if frameon :
2110
- original_frameon = self .get_frameon ()
2111
- self .set_frameon (frameon )
2109
+ original_frameon = self .patch . get_visible ()
2110
+ self .patch . set_visible (frameon )
2112
2111
2113
2112
self .canvas .print_figure (fname , ** kwargs )
2114
2113
2115
2114
if frameon :
2116
- self .set_frameon (original_frameon )
2115
+ self .patch . set_visible (original_frameon )
2117
2116
2118
2117
if transparent :
2119
2118
for ax , cc in zip (self .axes , original_axes_colors ):
0 commit comments