def adjust_bbox_png(fig, bbox_inches):
    '\n    adjust_bbox for png (Agg) format\n    '
    tr = fig.dpi_scale_trans
    _bbox = TransformedBbox(bbox_inches, tr)
    (x0, y0) = (_bbox.x0, _bbox.y0)
    fig.bbox_inches = Bbox.from_bounds(0, 0, bbox_inches.width, bbox_inches.height)
    (x0, y0) = (_bbox.x0, _bbox.y0)
    (w1, h1) = (fig.bbox.width, fig.bbox.height)
    fig.transFigure._boxout = Bbox.from_bounds((- x0), (- y0), w1, h1)
    fig.transFigure.invalidate()
    fig.bbox = TransformedBbox(fig.bbox_inches, tr)
    fig.patch.set_bounds((x0 / w1), (y0 / h1), (fig.bbox.width / w1), (fig.bbox.height / h1))
adjust_bbox for png (Agg) format
def adjust_bbox_png(fig, bbox_inches):
    '\n    \n    '
    tr = fig.dpi_scale_trans
    _bbox = TransformedBbox(bbox_inches, tr)
    (x0, y0) = (_bbox.x0, _bbox.y0)
    fig.bbox_inches = Bbox.from_bounds(0, 0, bbox_inches.width, bbox_inches.height)
    (x0, y0) = (_bbox.x0, _bbox.y0)
    (w1, h1) = (fig.bbox.width, fig.bbox.height)
    fig.transFigure._boxout = Bbox.from_bounds((- x0), (- y0), w1, h1)
    fig.transFigure.invalidate()
    fig.bbox = TransformedBbox(fig.bbox_inches, tr)
    fig.patch.set_bounds((x0 / w1), (y0 / h1), (fig.bbox.width / w1), (fig.bbox.height / h1))