Search code examples
pythonpandasmatplotlibmplfinance

mplfinance: plot a line without using an "ohlc" DataFrame?


I would like to plot a line without using a "default ohlc data". In this case, I'm using the data in the Github.

How can I do this?

import pandas as pd
import mplfinance as mpf
import matplotlib.animation as animation
import numpy as np


path_ = 'C:\Mypath'

intraday = pd.read_csv(path_+'SP500_NOV2019_IDay.csv',index_col=0,parse_dates=True)
intraday.index.name = 'Date'


# mpf.plot(intraday,type='line')    #ohlc DataFrame.. ok


int_Low = intraday.loc[:,'Low']     #non ohlc DataFrame
mpf.plot(data=int_Low,type='line')  #doesn't work

Solution

  • It seems that mplfinance is designed around a base OHLC chart. One way to make a Low line is to add it to the chart:

    lowline = mpf.make_addplot(intraday['Low'], type='line')
    mpf.plot(intraday, addplot=lowline)