You can use the matplotlib
library to plot the graph, see:
import matplotlib.pyplot as plt
def obterProgresso( linha ):
p = [ 0 ]
x = 0
for i in linha:
if i == 0:
x-=1
else:
x+=1
p.append(x)
return p;
Linha1 = [1,1,1,0,1,0,1]
Linha2 = [0,0,0,0,1,1,1]
Prog1 = obterProgresso( Linha1 )
Prog2 = obterProgresso( Linha2 )
print "Linha1 = ", Prog1
print "Linha2 = ", Prog2
plt.plot( Prog1, 'bo' );
plt.plot( Prog1, 'k--', color='blue' );
plt.plot( Prog2, 'ro' );
plt.plot( Prog2, 'k--', color='red' );
plt.grid(True)
plt.xlabel("Tempo")
plt.ylabel("Progresso")
plt.show()
Output:
Progressions:
Linha1 = [0, 1, 2, 3, 2, 3, 2, 3]
Linha2 = [0, -1, -2, -3, -4, -3, -2, -1]