0

I plot a candlestick chart with python 3 using matplotlib. There is one thing that looks not as I would like. It's lines in candles body (see the image below). Thus the question:

Is there a way to avoid their presence? Also, I need to keep the black/white style.

enter image description here

2 Answers 2

2

As seen e.g. in this answer, you can obtain the lines and patches of the candlestick graph and change their properties to your likings:

lines, patches = candlestick_ohlc(ax, quotes, width=0.5)
for line, patch in zip(lines, patches):
    patch.set_edgecolor("k")
    patch.set_linewidth(0.72)
    patch.set_antialiased(False)
    line.set_color("k")
    line.set_zorder(0) # make lines appear behind the patches
    line.set_visible(False) # make them invisible
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, that exactly what I've asked! But the last line deletes all of the shadows, thus it should be removed.
All of those those are some options you have. You may choose which ones to use for yourself.
2

I developed finplot, to get a better API and higher performance. finplot does not have this rendering bug on hollow candles by default.

import finplot as fplt
import yfinance as yf

df = yf.download('AAPL', '2020-05-01')

ax,axv = fplt.create_plot('Apple Inc.', rows=2)
cplot = fplt.candlestick_ochl(df[['Open','Close','High','Low']], ax=ax)
vplot = fplt.volume_ocv(df[['Open','Close','Volume']], ax=axv)

cplot.colors.update(dict(bull_frame='#000', bull_body='#fff', bull_shadow='#000', bear_frame='#000', bear_body='#000', bear_shadow='#000'))
vplot.colors.update(dict(bull_frame='#000', bull_body='#fff', bear_frame='#000', bear_body='#000'))

fplt.show()

finplot b/w

3 Comments

I used finplot for candles form binance. I loaded candles from csv file, next i tried to plot those candles. The problem is that all candles are looking like growing candles. I do not have right one colors. I thing i pass columns in the correct order candles = df[['time','open','close','high','low']]. Howewer when i try code pypi.org/project/finplot from example 2, all is working fine. Have you advice for me?
@luki Post an example of your problem including data in the discussions and I'll have a look.
@ Jonas. I paste my code and info about data there: github.com/highfestiva/finplot/discussions/277

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.