Skip to content

Instantly share code, notes, and snippets.

@yhirano
Created July 14, 2020 15:08
Show Gist options
  • Select an option

  • Save yhirano/b2032dbbeba7c18bb71b3b7eb40dfb31 to your computer and use it in GitHub Desktop.

Select an option

Save yhirano/b2032dbbeba7c18bb71b3b7eb40dfb31 to your computer and use it in GitHub Desktop.
CSV plot with lowpassfilter.
import pandas as pd
import matplotlib.pyplot as plt
def lowpass(values, strength):
result = []
f = 0
for v in values:
if not result:
result.append(v)
f = v
else:
f = ((1 - strength) * f) + (strength * v)
result.append(f)
return result
df = pd.read_csv('file.csv', names=['x', 'y'])
t = []
for v in df['x']:
t.append(v - df['x'][0])
plt.xlabel("x")
plt.ylabel("y")
plt.plot(t, df['y'], label='Raw')
plt.plot(t, lowpass(df['y'], 0.1), label='a=0.1')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment