55from matplotlib .transforms import Bbox , TransformedBbox , Affine2D
66
77
8- def adjust_bbox (fig , bbox_inches , fixed_dpi = None ):
8+ def adjust_bbox (fig , bbox_inches , renderer , fixed_dpi = None ):
99 """
1010 Temporarily adjust the figure so that only the specified area
1111 (bbox_inches) is saved.
@@ -25,7 +25,7 @@ def adjust_bbox(fig, bbox_inches, fixed_dpi=None):
2525 for ax in fig .axes :
2626 locator = ax .get_axes_locator ()
2727 if locator is not None :
28- ax .apply_aspect (locator (ax , None ))
28+ ax .apply_aspect (locator (ax , renderer ))
2929 locator_list .append (locator )
3030 current_pos = ax .get_position (original = False ).frozen ()
3131 ax .set_axes_locator (lambda a , r , _pos = current_pos : _pos )
@@ -70,7 +70,7 @@ def restore_bbox():
7070 return restore_bbox
7171
7272
73- def process_figure_for_rasterizing (fig , bbox_inches_restore , fixed_dpi = None ):
73+ def process_figure_for_rasterizing (fig , bbox_inches_restore , renderer , fixed_dpi = None ):
7474 """
7575 A function that needs to be called when figure dpi changes during the
7676 drawing (e.g., rasterizing). It recovers the bbox and re-adjust it with
@@ -79,6 +79,6 @@ def process_figure_for_rasterizing(fig, bbox_inches_restore, fixed_dpi=None):
7979
8080 bbox_inches , restore_bbox = bbox_inches_restore
8181 restore_bbox ()
82- r = adjust_bbox (fig , bbox_inches , fixed_dpi )
82+ r = adjust_bbox (fig , bbox_inches , renderer , fixed_dpi )
8383
8484 return bbox_inches , r
0 commit comments