from typing import Iterable
from typing import Tuple


def get_text_width_height(
    iterable: Iterable, font_size: float, target_axis: str = "y"
) -> Tuple[float, float]:
    """Estimate width and height required for a sequence of labels in a plot

    This is intended to be used for axis tick labels.

    Args:
        iterable: Sequence, series, array etc. of strings which will be
            used as axis labels
        font_size: font size used for the labels (e.g. tick label fontsize)
        target_axis: determines which dimension is width and which
        dimension is height for the labels. For 'x' rotation=90 is
        assumed.

    Returns:
        width, height required for the labels
    """

    height = font_size * 1 / 72 + 2 / 72
    max_text_length = max([len(s) for s in iterable])
    max_width = height * 0.6 * max_text_length
    if target_axis == "y":
        return max_width, height
    elif target_axis == "x":
        return height, max_width
    else:
        raise ValueError(f"Unknown target axis {target_axis}")