plot_3d_trajectory.py
def plot_3d_video(df, points_drawn_per_frame=50, filename='trajectory'):
    """
    Plots a 3d video showing the trajectory of the head position in space.

    Usage:
    data = get_location_dataframe(matrix_dataframe)
    plot_3d_video(df)

    """
    fig, ax = set_3d_axes()
    # Load data into numpy array
    data = np.array((df['X'].values, df['Y'].values, df['Z'].values))
    line = ax.plot(data[0, 0:1], data[2, 0:1], data[1, 0:1])[0]  # Note: Z and Y axes are swapped here

    ani = animation.FuncAnimation(fig,
                                  update_lines,
                                  int(data.shape[1] / points_drawn_per_frame),
                                  fargs=(data, line, points_drawn_per_frame),
                                  interval=1,
                                  blit=False)

    filename = filename + '.mp4' if filename[-4:] != '.mp4' else filename
    ani.save(filename, fps=30, extra_args=['-vcodec', 'libx264'])

    Plots a 3d video showing the trajectory of the head position in space.

    Usage:
    data = get_location_dataframe(matrix_dataframe)
    plot_3d_video(df)

    
Plots a 3d video showing the trajectory of the head position in space.
Plots a 3d video showing the trajectory of the head position in space .
def plot_3d_video(df, points_drawn_per_frame=50, filename='trajectory'):
    fig, ax = set_3d_axes()
    data = np.array((df['X'].values, df['Y'].values, df['Z'].values))
    line = ax.plot(data[0, 0:1], data[2, 0:1], data[1, 0:1])[0]  
    ani = animation.FuncAnimation(fig,
                                  update_lines,
                                  int(data.shape[1] / points_drawn_per_frame),
                                  fargs=(data, line, points_drawn_per_frame),
                                  interval=1,
                                  blit=False)
    filename = filename + '.mp4' if filename[-4:] != '.mp4' else filename
    ani.save(filename, fps=30, extra_args=['-vcodec', 'libx264'])
def plot_3d_video ( df , points_drawn_per_frame = 50 , filename = 'trajectory' ) : fig , ax = set_3d_axes ( ) data = np . array ( ( df [ 'X' ] . values , df [ 'Y' ] . values , df [ 'Z' ] . values ) ) line = ax . plot ( data [ 0 , 0 : 1 ] , data [ 2 , 0 : 1 ] , data [ 1 , 0 : 1 ] ) [ 0 ] ani = animation . FuncAnimation ( fig , update_lines , int ( data . shape [ 1 ] / points_drawn_per_frame ) , fargs = ( data , line , points_drawn_per_frame ) , interval = 1 , blit = False ) filename = filename + '.mp4' if filename [ - 4 : ] != '.mp4' else filename ani . save ( filename , fps = 30 , extra_args = [ '-vcodec' , 'libx264' ] )
Plots a 3d video showing the trajectory of the head position in space.
Plots a 3d video showing the trajectory of the head position in space .
"""
    Plots a 3d video showing the trajectory of the head position in space.

    Usage:
    data = get_location_dataframe(matrix_dataframe)
    plot_3d_video(df)

    """ # Load data into numpy array # Note: Z and Y axes are swapped here
df
points_drawn_per_frame
filename