0
My Python algorithm is running perfectly, I just can’t generate the graph! I couldn’t identify the error... What’s wrong?
import matplotlib.pyplot as plt
va=float(input('Digite o valor a ser aplicado: '))
juros=1.05
inflacao=1.02
saque=25000
vaplicacao=[va]
nsaque=0
vsaque=[]
while saque<=vaplicacao[len(vaplicacao)-1]:
va=(vaplicacao[len(vaplicacao)-1]*juros)-(saque)
vaplicacao.append(va)
nsaque=nsaque+1
saque=saque*inflacao
vsaque.append(nsaque)
plt.plot(vsaque,vaplicacao,'b-')
plt.title('Saldo x Saque')
plt.grid(True)
plt.xlabel('Saque ao longo dos anos')
plt.ylabel('Saldo ao longo dos anos')
plt.show()
And what are the entries you are using? Because all the tests I did got the error "Valueerror: x and y must have same first Dimension, but have shapes".
– Woss
I need the graph to show on the "X" axis the vector "vsaque" and on the "Y" axis the vector "vaplication". This is the error that appears here. Traceback (Most recent call last): File "C: Users Guilherme Desktop EXERCISE 5 LIST 5.py", line 18, in <module> plt.Plot(vsaque,vaplicacao,'b-') File "C: Users Guilherme Appdata Local Programs Python Python36-32 lib site-Packages matplotlib pyplot.py", line 3358, in Plot Ret = Ax.Plot(*args, **kwargs)
– Guilherme
But wasn’t it running perfectly? It got confused now. This error appears to you too?
– Woss
It’s just that I ran the algorithm without the information to generate the graph and had him print the "vsaque" and "vaplication" vector. With this I could see if the algorithm was calculating correctly and is.. Now I need it to generate a graph with these vectors, only when I entered the codes to generate the graph appears these errors reported
– Guilherme