From 31d344d852af825d2b6817823ce964b8fedfdf91 Mon Sep 17 00:00:00 2001 From: Ubaidullah Khan <33365560+ubaidsworld@users.noreply.github.com> Date: Wed, 31 Jul 2019 16:24:23 +0530 Subject: [PATCH] Lets separate the candle with respect to color added a code so that person can separate the display of the candles in understanding format. --- mpl_finance.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mpl_finance.py b/mpl_finance.py index c06b337..b60e308 100644 --- a/mpl_finance.py +++ b/mpl_finance.py @@ -553,7 +553,7 @@ def candlestick2_ochl(ax, opens, closes, highs, lows, width=4, def candlestick2_ohlc(ax, opens, highs, lows, closes, width=4, - colorup='k', colordown='r', + colorup='k', colordown='r',colordoji='k', alpha=0.75): """Represent the open, close as a bar line and high low range as a vertical line. @@ -605,11 +605,20 @@ def candlestick2_ohlc(ax, opens, highs, lows, closes, width=4, colorup = mcolors.to_rgba(colorup, alpha) colordown = mcolors.to_rgba(colordown, alpha) - colord = {True: colorup, False: colordown} - colors = [colord[open < close] - for open, close in zip(opens, closes) - if open != -1 and close != -1] - + colordoji = mcolors.to_rgba(colordoji, alpha) + # colord = {True: colorup, False: colordown} + # colors = [colord[open < close] + # for open, close in zip(opens, closes) + # if open != -1 and close != -1] + colors = [] + for open, close in zip(opens, closes): + if open != -1 and close != -1: + if open < close: + colors.append(colorup) + elif open > close: + colors.append(colordown) + else: + colors.append(colordoji) useAA = 0, # use tuple here lw = 0.5, # and here rangeCollection = LineCollection(rangeSegments,