Skip to content

Commit 254518a

Browse files
committed
Feature Request: Ability to plot step /staircase lines implemented Issue #367
1 parent 385b27c commit 254518a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/mplfinance/plotting.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,13 @@ def _addplot_columns(panid,panels,ydata,apdict,xdates,config):
909909
width = apdict['width'] if apdict['width'] is not None else 1.6*config['_width_config']['line_width']
910910
alpha = apdict['alpha']
911911
ax.plot(xdates,ydata,linestyle=ls,color=color,linewidth=width,alpha=alpha)
912+
elif aptype == 'step':
913+
where = apdict['where']
914+
ls = apdict['linestyle']
915+
color = apdict['color']
916+
width = apdict['width'] if apdict['width'] is not None else 1.6*config['_width_config']['line_width']
917+
alpha = apdict['alpha']
918+
ax.step(range(len(xdates)),ydata,where = where,linestyle=ls,color=color,linewidth=width,alpha=alpha)
912919
else:
913920
raise ValueError('addplot type "'+str(aptype)+'" NOT yet supported.')
914921

@@ -995,7 +1002,8 @@ def _auto_secondary_y( panels, panid, ylo, yhi ):
9951002
def _valid_addplot_kwargs():
9961003

9971004
valid_linestyles = ('-','solid','--','dashed','-.','dashdot','.','dotted',None,' ','')
998-
valid_types = ('line','scatter','bar', 'ohlc', 'candle')
1005+
valid_types = ('line','scatter','bar', 'ohlc', 'candle','step')
1006+
valid_wheres = ('pre','post','mid')
9991007

10001008
vkwargs = {
10011009
'scatter' : { 'Default' : False,
@@ -1055,6 +1063,9 @@ def _valid_addplot_kwargs():
10551063

10561064
'yscale' : { 'Default' : None,
10571065
'Validator' : lambda value: _yscale_validator(value) },
1066+
1067+
'where' : { 'Default' : 'pre',
1068+
'Validator' : lambda value : value in valid_wheres },
10581069
}
10591070

10601071
_validate_vkwargs_dict(vkwargs)

0 commit comments

Comments
 (0)