'Trying to plot Earnings and Stock price in the same graph

I'm trying to plot the stock price and the earnings on the graph but for some reason I'm getting this:

Graph1

Please see my code below:

import matplotlib.pyplot as plt
import yfinance as yf
import pandas
import pandas_datareader
import matplotlib

t = yf.Ticker("T")

df1 = t.earnings
df1['Earnings'].plot(label = 'earnings', figsize = (15,7), color='green')
print(df1)

df2 = t.history(start = '2018-01-01', end = '2021-01-01', actions = False, rounding = True)
df2['Close'].plot(label = 'price', figsize = (15,7),color = 'blue')

plt.show()

Could someone help me?

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source