def animate(idx, *fargs):
    """
    Animate the sine waves by shifting them along the axes.

    Calculates the sine waves anew shifted a tiny bit more.
    fargs needs to supply the tuple: (sine_waves, lines, x_offsets, y_offsets)
    The order is important. sine_calc is the output of create_sine_func, lines
    is the list of the plots in the figure, and x- and y-offsets are the list
    of offsets to be applied to the sine waves.

    Since the top-left and bottom curve move to the left, the x-offset is
    supplied as is. For the top-right curve it is negated to move the curve to
    the right. Only the bottom curve is shifted on the y-axis, hence the
    y-offsets for the top curves are 0.

    The index of the animation is important to access how much to shift the curves.

    Args:
        idx: int
            The index of the animation playing. Used to access offsets.
        fargs: tuple
            A tuple containing the sine_calc function, a list of 2D-lines to 
            replace the y-data on, the x-offsets and y-offsets to index with idx

    Returns:
        lines: list
            The list of altered 2D-Line objects to be plotted in the next frame
    """
    sine_waves = fargs[0] # extract function object
    lines = fargs[1] # extract list of artists
    x_off = fargs[2][idx] # extract offset for this animation frame
    y_off = fargs[3][idx]

    # create the lists supplied to the sine_waves function
    x_offs = [x_off, -x_off, x_off]
    y_offs = [0, 0, y_off]

    # calculate the new sine waves
    sines = sine_waves(x_offs, y_offs)

    # and replace the data
    for i in range(len(lines)):
        lines[i].set_ydata(sines[i])

    return lines