KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have created a 3D plot surface from a file and I'm trying to animate the plot. I have read the examples in the matplotlib webpage and other examples in SO, and notice that I need to create an update function to loop through the values in the file and then create a matplotlib.animation object but I don't understand how to do it. I would appreciate very much if someone could explain me the syntax of the update function and how to use it in the matplotlib.animation object. My data is a multidimensional array with 498 lines and for each line i have an array with 64x128 values. Data is organized in the following way: Data is a time series from a force plate and each one of the 500 lines is a frame, which means that this trial lasts 10 seconds. For each frame I have another array with 64x128 values. This is my code until now: from mpl_toolkits.mplot3d import * import matplotlib.pyplot as plt import numpy as np from random import random, seed from matplotlib import cm from mpl_toolkits.mplot3d import axes3d import matplotlib.animation as animation source_path = "c:\\Projecto\\" destination_path = "c:\\Projecto\\EntirePlate\\" #fid = np.loadtxt(source_path + "rolloff_xls.txt",dtype=str) fid_MP = open(source_path + "101mp - Entire plate roll off.xls","Ur") lines_MP = fid_MP.readlines() fid_MP.close() values_MP = [] for i in lines_MP: if i[0].isdigit(): values_MP.append(i) values = np.loadtxt(values_MP,dtype=float) new_values_MP =[] for i in range(0,(len(values_MP)/64)): for j in range(0,64): new_values_MP.append([[i],[j],values[j]]) new_values_MP = np.asarray(new_values_MP) fig = plt.figure() ax = fig.gca(projection='3d') # to work in 3d plt.hold(True) x_surf = np.arange(0,128) # generate a mesh y_surf = np.arange(0,64) x_surf, y_surf = np.meshgrid(x_surf, y_surf) z_surf = [] for i in r
Tags (comma-separated)
Save Edits
Cancel