Animates x and y - where x and y are 1d arrays of x and y 
    positions and it plots x[i:i+NTrailPoints] and y[i:i+NTrailPoints]
    against each other and iterates through i.

def animate_2Dscatter(x, y, NumAnimatedPoints=50, NTrailPoints=20, 
    xlabel="", ylabel="",
    xlims=None, ylims=None, filename="testAnim.mp4", 
    bitrate=1e5, dpi=5e2, fps=30, figsize = [6, 6]):
    """
    Animates x and y - where x and y are 1d arrays of x and y 
    positions and it plots x[i:i+NTrailPoints] and y[i:i+NTrailPoints]
    against each other and iterates through i. 

    """
    fig, ax = _plt.subplots(figsize = figsize)

    alphas = _np.linspace(0.1, 1, NTrailPoints)
    rgba_colors = _np.zeros((NTrailPoints,4))
    # for red the first column needs to be one
    rgba_colors[:,0] = 1.0
    # the fourth column needs to be your alphas
    rgba_colors[:, 3] = alphas


    scatter = ax.scatter(x[0:NTrailPoints], y[0:NTrailPoints], color=rgba_colors)

    if xlims == None:
        xlims = (min(x), max(x))
    if ylims == None:
        ylims = (min(y), max(y))

    ax.set_xlim(xlims)
    ax.set_ylim(ylims)
    ax.set_xlabel(xlabel)
    ax.set_ylabel(ylabel)

    def animate(i, scatter):
        scatter.axes.clear() # clear old scatter object
        scatter = ax.scatter(x[i:i+NTrailPoints], y[i:i+NTrailPoints], color=rgba_colors, animated=True) 
        # create new scatter with updated data
        ax.set_xlim(xlims)
        ax.set_ylim(ylims)
        ax.set_xlabel(xlabel)
        ax.set_ylabel(ylabel)
        return scatter,


    ani = _animation.FuncAnimation(fig, animate, _np.arange(1, NumAnimatedPoints),
                                  interval=25, blit=True, fargs=[scatter])
    ani.save(filename, bitrate=bitrate, dpi=dpi, fps=fps)
    return None