Created
June 15, 2013 13:14
-
-
Save DomNomNom/5788088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
rages = [] | |
def smooth(interable, size): | |
cache = interable[:size] | |
out = [] | |
for i in interable[size:]: | |
out.append(sum(cache)/size) | |
cache.pop(0) | |
cache.append(i) | |
out.append(sum(cache)/size) | |
return out | |
smoothing = 5 | |
with open("rageData.txt") as f: | |
for line in f: | |
data = line.split() | |
print data | |
if data[0] == "decrease:": | |
floats = map(float, data[1:]) | |
rages.append(( | |
smooth(floats, smoothing), | |
[sum(floats)/len(floats)] * (len(floats)-smoothing) | |
)) | |
colorMap = { | |
0 : 'b', | |
1 : 'g', | |
2 : 'r', | |
3 : 'c', | |
4 : 'm', | |
5 : 'y', | |
6 : 'k', | |
7 : 'w', | |
} | |
for i, tup in enumerate(rages): | |
rage, average = tup | |
x = range(0, len(rage)) | |
plt.plot(x, rage, color=colorMap[i]) | |
x = range(0, len(average)) | |
plt.plot(x, average, color=colorMap[i]) | |
# y = [sum(rage)/len(rage)] * len(rage) | |
# plt.plot(x,y) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment