Skip to content

Instantly share code, notes, and snippets.

@TonyMooori
Created February 1, 2016 15:51
Show Gist options
  • Save TonyMooori/1906b776b307761b8188 to your computer and use it in GitHub Desktop.
Save TonyMooori/1906b776b307761b8188 to your computer and use it in GitHub Desktop.
振り子の座標のプロットプログラム
#coding:utf-8
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# 最初のデータはWebカメラの調子が悪いため無視
data = pd.read_csv("output.csv")
data = data[50:]
# 計算しやすいように取り出す
t = data['t']
x = data['x']
y = data['y']
# x,yは平均(振動の中心)を0に持ってこさせる
x = x - np.average(x)
y = y - np.average(y)
# 時間はt[0]が0になるようにしとく
# (pandasを使うとt[0]という表現ができないのでこうしました)
t = t - np.min(t)
# 凡例とともに表示
plt.plot(t,x,label="x")
plt.plot(t,y,label="y")
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment