- python
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
for n in range(1,4):
file = 'pendulum_' + str(n) + '.csv'
fps = 59
time_difference = 1/fps
data = pd.read_csv(file)
x_centered = (data['x'].values - np.mean(data['x']))
y_centered = (data['y'].values - np.mean(data['y']))
time = np.arange(len(x_centered))*time_difference
plt.figure()
plt.plot(time, x_centered, label = 'x centered')
plt.plot(time, y_centered, label = 'y centered')
plt.xlabel('Time (s)')
plt.ylabel('Displacement (pixels)')
plt.title('Pendulum ' + str(n) + ' centered data')
plt.legend()
plt.grid(True)
plt.savefig('Pendulum_' + str(n) + '_centered_data')
plt.show()
Подробнее здесь: https://stackoverflow.com/questions/798 ... ng-a-graph
Мобильная версия