from typing import Union
from typing import List
from typing import Tuple


def __plot_limits(ax,
                  limits: Union[List[float], float],
                  colours: Union[List[List[float]], List[Tuple[float]], List[str]],
                  linestyles: List[str]) -> None:
    """
    Add limit markers to a given plot (e.g. add line marking start of QRS complex)

    Parameters
    ----------
    ax
        Handle to axis
    limits: list of float or float
        Limits to plot on the axis
    colours : list of list/tuple of float or list of str
        RGB values of colours for the individual limits to plot. For plotting n limits, then should be given as
        [[R1, G1, B1], [R2, G2, B2], ... [Rn, Gn, Bn]]
    linestyles : list of str
        Linestyles to plot for each limit.
    """

    if not isinstance(limits, list):
        limits = [limits]
    assert len(limits) <= len(colours), "Incompatible length of limits to plot and colours"
    assert len(limits) <= len(linestyles), "Incompatible length of limits to plot and linestyles"
    for (sim_limit, sim_colour, sim_linestyle) in zip(limits, colours, linestyles):
        for key in ax:
            ax[key].axvline(sim_limit, color=sim_colour, alpha=0.5, linestyle=sim_linestyle)

    return None