mplfinance icon indicating copy to clipboard operation
mplfinance copied to clipboard

How to push my marker subplot in front of the main plot wick? (problem with candles and wicks)

Open Omri93h opened this issue 3 years ago • 2 comments

Hello. when im adding a mark(I've used 'v') with mpf.make_addplot , my subplot is at a better visual priority from the candles, but not the wicks. image

is that a bug? is there anything im doing wrong? I've used "inherit" in styling, and my make_addplot is pretty simple.

image image

Omri93h avatar Mar 18 '21 16:03 Omri93h

You are not doing anything wrong. This has to do with zorder as you noted over here.

Until zorder is implemented, you can try two things:

  1. Plot your markers further away from the candles so that they don't overlap with the candles: Click here for example code for doing this.

  2. Pass alpha=0.5 in to your make_addplot() call so that the markers are somewhat transparent.

Please also see my comment here if you have not already seen it.

DanielGoldfarb avatar Mar 18 '21 17:03 DanielGoldfarb

In the meanwhile I can suggest a small hack.. In plotting.py file which is in the installation folder of mplfinance add zorder in the relevant line of code (I also added edgecolor as shown in the code below):

if aptype == 'scatter': size = apdict['markersize'] mark = apdict['marker'] color = apdict['color'] alpha = apdict['alpha']

    if isinstance(mark,(list,tuple,np.ndarray)):
        _mscatter(xdates,ydata,ax=ax,m=mark,s=size,color=color,alpha=alpha)
    else:
        ax.scatter(xdates,ydata,s=size,marker=mark,color=color,alpha=alpha,zorder=3,edgecolor='white')

Dror77 avatar Jul 10 '21 15:07 Dror77