def get_figsize(figsize, nrows_and_cols):
    """ If `figsize` is a tuple (w, h), returns (w, h), otherwize
    consider figsize as the width and returns corresponding (w, h)
    depending on nrows and ncols. """
    nrows, ncols = nrows_and_cols
    try:
        w, h = figsize
    except:
        w = figsize
        h = figsize / ncols * nrows
    return w, h