2
Hello,
I am training in creating graphics in Python with matplotlib. For this, I am importing an HTML with WEGE3 action history.
df_history = pd.read_html("https://br.financas.yahoo.com/quote/WEGE3.SA/history?p=WEGE3.SA")
I took out the duplicates (there were only 2):
df_remove = df_history[0].drop_duplicates(subset=['Data'])
And I took the last line:
yy = df_remove['Fechamento*'].drop(100)
xx = df_remove['Data'].drop(100)
I defined the Abels:
plt.xlabel('Data')
plt.ylabel('Preço')
The problem happens here: When I go to display the chart, it gets wrong. I increased the size just to see if the values of X and Y appeared correct on the chart and appear, but the drawing of the graph itself, is wrong:
f = plt.figure()
f.set_figwidth(28)
f.set_figheight(28)
plt.plot(xx, yy)
plt.show()
This is the (wrong) graph that appears:
To confirm if the graph is right or wrong, I took the same data and put in Excel.
This would be the correct chart:
I spent time trying to analyze but I couldn’t find where the problem is.
I don’t know if this information is relevant but, I am running this code on Google Colab.
Thank you.
Wouldn’t it be better to chart from the csv made available on the imported HTML page itself?
– Augusto Vasques
With CVS it worked. But as my goal is to train, I would like to understand my mistake using the same HTML :)
– Thiago De Almeida Pereira