Turn two data lists into a graph with two parallel lines

Asked

Viewed 770 times

0

Guys. I am since yesterday trying to do something that is very simple in Excel, but not in Python.

I have two lists. Flap1 = [1,1,0,1,0,1] and Flap2 = [0,0,0,0,1,1,1]

What I need to do is create a chart with these two lists and put them in parallel. As if it were a progress chart. Example 1, Example 2, Example 3. Where for example. If the value is 1 the line goes up, and if the value is 0 the line goes down.

I have already managed to create a graph that sums the values of these lines and shows in a bar graph. But that doesn’t allow me to see if the data in question is progressing in relation to time.

1 answer

3

You can use the library matplotlib to plot the chart, see only:

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()

Exit:

inserir a descrição da imagem aqui

Progressions:

Linha1 =  [0, 1, 2, 3, 2, 3, 2, 3]
Linha2 =  [0, -1, -2, -3, -4, -3, -2, -1]
  • Yes. Thank you very much . Here’s what I want to do "https://drive.google.com/open?id=1gHjtnm8OKtNH0Evlhv6Src1VIIZ1_BXR " is a little program for me to track my progress in doing my daily tasks.

  • Ready. Here’s the current version " https://drive.google.com/open?id=1zZYnXYcG6y_cbrtWXu7sKMD7UBMPl9-x ", that’s the point I wanted. . I will call Task Manager DDN

Browser other questions tagged

You are not signed in. Login or sign up in order to post.