def get_ax_size_in_pixels(fig, ax):
    """ Get the size of axis frame in pixels """
    bbox = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
    return bbox.width * fig.dpi - 7, bbox.height * fig.dpi - 7
