Search code examples
pandasdataframeplotyahoo-financemplfinance

How to add point on every line ( ohlcv plotted as line) change in mplfinance?


enter image description here

I'd like to plot a image like the one above (photoshopped).

I tried using mpf.make_addplot(data,type='scatter'), but the dataframe (data) dont match the line.

The line represents the middle of the candle so i thought about making a list with all halves of the candles and then applying points in those coordinates, but i am sure there is a better method Is there a way to solve and automate this?

Some code:

import mplfinance as mpf

# Here i get the dataframe from yahoo and get the last 50 candles

savefig = dict(fname="test.jpg", bbox_inches="tight")
mpf.plot(data, type='line', axisoff=True, savefig=savefig)

Thanks in advance.


Solution

  • As you can see from the code here type=line plots the close price, not the middle of the candle as you thought.

    Therefore mpf.make_addplot(data,type='scatter') should work for you, if you pass in the close prices to make_addplot().