Multiple Plots Are Not Showing Up In A Single Figure
Am using following code to print to plot stock prices and a vertical line on one graph. But of them work individually but i cant plot both on one graph import datetime as dt import
Solution 1:
Its always good to get the figure and the axes handles such that subsequent manipulation can be done easily.
import datetime as dt
import yfinance as yf
import matplotlib.pyplot as plt
# added following line to avoid a warning of future support of datetime
# https://github.com/pandas-dev/pandas/issues/18301#issuecomment-344580274
from pandas.plotting import register_matplotlib_converters
# Get the data for the stock Apple by specifying the stock ticker, start date, and end date
data = yf.download('AAPL','2020-02-01','2020-02-10', interval='15m')
register_matplotlib_converters()
fig, ax = plt.subplots(1, figsize=(10, 5))
ax.plot(data.Close)
ax.axvline(dt.datetime(2020, 2, 2), color='red')
plt.show()
Post a Comment for "Multiple Plots Are Not Showing Up In A Single Figure"