def _findlims(data, scale):
    """
    Analyses the energy levels and wavefunctions to calculate axis-limits
    for the plot.

    Args:
        data (dict): The data containing x-coordinates, wavefunctions and
            energy levels. Needs to have keys 'xcoords', 'wfuncs', 'energies'.
        scale (float): The scale that will be applied to the wavefunctions.

    Returns:
        touple: The limits for the x- and y-axis.

    """
    energies, wfuncs = data['energies'], data['wfuncs'].T
    minval = min(scale * wfuncs[0] + energies[0])
    maxval = max(scale * wfuncs[-1] + energies[-1])
    extraspace = (maxval - minval) / 10
    xlim = (data['xcoords'][0], data['xcoords'][-1])
    ylim = (minval - extraspace, maxval + extraspace)

    return xlim, ylim