I have the following code which plots intraday stocks data.
import pandas as pd, mplfinance as mpf, matplotlib.pyplot as plt
from pandas_datareader import data as web
import datetime
from datetime import timedelta
from dateutil.relativedelta import relativedelta
import yfinance as yf
yf.download(tickers='goog', start=datetime.datetime.now()-relativedelta(days=4), end= datetime.datetime.now(), interval="5m").plot(y="Close")
This produces the following plot as you can see it is also plotting a line through dates where no data is available. Is there anyway i can skip the days where data is not available?
As you can see
If you use MPL, it will automatically handle the x-axis time series.
df = yf.download(tickers='goog', start=datetime.datetime.now()-relativedelta(days=4), end=datetime.datetime.now(), interval="5m")
mpf.plot(df, figratio=(8,4), type='line', style='yahoo')