def _y_limits(ref_DFT, y):
    """
    Sets the y_limits of each plot to encompass both the data points and reference data, making sure the distributions are to the same scale.

    Args:
        ref_DFT (np.array): 1D array of reference lattice parameter values in same order as labels.
        y (np.array): lattice parameters for each strucutre of the training set using the given potential.

    Returns:
        tuple: Minimum and maximum limits for the y-axis.
    """ 
    if ref_DFT <= y.min():
        ylims = (ref_DFT-(ref_DFT*0.002), y.max()+(y.max()*0.002))
    elif ref_DFT >= y.max():
        ylims = (y.min()-(y.min()*0.002), ref_DFT+(ref_DFT*0.002))
    else:
        ylims = (y.min()-(y.min()*0.002), y.max()+(y.max()*0.002))
    return ylims