import warnings


def _determine_plot_height(figure_height, y_max, n_params, n_groups):
    """Calculate the height alloted to each parameter plot in pixels.

    Args:
        figure_height (int): height of figure in pixels
        y_max (float): maximum entry on any y-axis in the plot
        n_params (int): number of params
        n_groups (int): number of parameter groups

    Returns:
        plot_height (int): Plot height in pixels.

    """
    if figure_height is None:
        plot_height = int(max(min(30 * y_max, 1000), 100))
    else:
        space_of_titles = n_groups * 50
        available_space = figure_height - space_of_titles
        plot_height = int(available_space / n_params)
        if plot_height < 50:
            warnings.warn(
                "The figure height you specified results in very small "
                "plots which may not render well. Adjust the figure height "
                "to a larger value or set it to None to get a larger plot. "
                "Alternatively, you can click on the Reset button "
                "on the right of the plot and your plot should render correctly."
            )
    return plot_height