@@ -2092,15 +2092,28 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
20922092 renderer = self .figure ._cachedRenderer
20932093 bbox_inches = self .figure .get_tightbbox (renderer )
20942094
2095- bbox_extra_artists = kwargs .pop ("bbox_extra_artists" , None )
2096- if bbox_extra_artists is None :
2097- bbox_extra_artists = self .figure .get_default_bbox_extra_artists ()
2095+ bbox_artists = kwargs .pop ("bbox_extra_artists" , None )
2096+ if bbox_artists is None :
2097+ bbox_artists = self .figure .get_default_bbox_extra_artists ()
2098+
2099+ bbox_filtered = []
2100+ for a in bbox_artists :
2101+ bbox = a .get_window_extent (renderer )
2102+ # print('{0:40} - {1.width:5}, {1.height:5} '
2103+ # '{1}'.format(type(a), bbox))
2104+ if a .get_clip_on ():
2105+ clip_box = a .get_clip_box ()
2106+ if clip_box is not None :
2107+ bbox = Bbox .intersection (bbox , clip_box )
2108+ clip_path = a .get_clip_path ()
2109+ if clip_path is not None and bbox is not None :
2110+ clip_path = clip_path .get_fully_transformed_path ()
2111+ bbox = Bbox .intersection (bbox ,
2112+ clip_path .get_extents ())
2113+ if bbox is not None and (bbox .width != 0 or
2114+ bbox .height != 0 ):
2115+ bbox_filtered .append (bbox )
20982116
2099- bb = [a .get_window_extent (renderer )
2100- for a in bbox_extra_artists ]
2101-
2102- bbox_filtered = [b for b in bb
2103- if b .width != 0 or b .height != 0 ]
21042117 if bbox_filtered :
21052118 _bbox = Bbox .union (bbox_filtered )
21062119 trans = Affine2D ().scale (1.0 / self .figure .dpi )
0 commit comments