def get_useful_info(fig):
    dpi = fig.get_dpi()
pngdpi = 100
scale_x = pngdpi / dpi
scale_y = pngdpi / dpi
for ax in fig.get_axes():
    for rect in ax.monkey_rectangles:
        corners = rect.get_bbox().corners()[::3]
pos = ax.transData.transform(corners)
left = pos[0, 0] * scale_x
width = (pos[1, 0] - pos[0, 0]) * scale_x
bottom = pos[0, 1] * scale_y
height = (pos[1, 1] - pos[0, 1]) * scale_y
yield left, width, bottom, height
Incorrect rectangle location in matplotlib