How to insert legend in a linear graph with 3 vectors in the Y axis?

0
x=['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez']
y=[]
z=[]
w=[]
for i in range (0,12,1):
    soma=np.sum(mprod[:,i])
    y.append(int(soma))
for j in range (0,12,1):
    estoque=np.sum(resultado[:,j])
    w.append(int(estoque))
for k in range (0,12,1):
    vendas=np.sum(totvendas[:,k])
    z.append(int(vendas))
plt.plot(x,y,'ro-',x,z,'go-',x,w,'bo-')
plt.title("Produção x Vendas x Estoque")
plt.grid(True)
plt.legend()
plt.xlabel("Mêses")
plt.show()
    
asked by anonymous 12.07.2018 / 22:23

1 answer

0

Exchange

plt.plot(x,y,'ro-',x,z,'go-',x,w,'bo-')

by

plt.plot(x,y, 'ro-', label='y')
plt.plot(x,z, 'go-', label='z')
plt.plot(x,w, 'bo-', label='w')
    
12.07.2018 / 23:34