def GetAxSize(fig, ax, dpi=False):
    """get width and height of a given axis.
	   output is in inches if dpi=False, in dpi if dpi=True
	"""
    bbox = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
    width, height = bbox.width, bbox.height
    if dpi:
        width *= fig.dpi
        height *= fig.dpi
    return width, height
