Skip to content

Commit f4c7849

Browse files
committed
added markevery feature to plotting.py
1 parent 9af7736 commit f4c7849

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

src/mplfinance/plotting.py

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ def _valid_plot_kwargs():
107107
'type' : { 'Default' : 'ohlc',
108108
'Description' : 'Plot type: '+str(_get_valid_plot_types()),
109109
'Validator' : lambda value: value in _get_valid_plot_types() },
110+
'markevery' : { 'Default' : None,
111+
'Description' : 'markevery: size color shape ',
112+
'Validator' : lambda value: isinstance(value,(tuple, list, int))},
113+
110114

111115
'style' : { 'Default' : None,
112116
'Description' : 'plot style; see `mpf.available_styles()`',
@@ -407,7 +411,8 @@ def plot( data, **kwargs ):
407411
moving averages, renko, etc.
408412
Also provide ability to plot trading signals, and/or addtional user-defined data.
409413
"""
410-
414+
import sys
415+
sys.stdout = sys.__stdout__
411416
config = _process_kwargs(kwargs, _valid_plot_kwargs())
412417

413418
# translate alias types:
@@ -492,6 +497,7 @@ def plot( data, **kwargs ):
492497
else:
493498
panels = _build_panels(fig, config)
494499
axA1 = panels.at[config['main_panel'],'axes'][0]
500+
warnings.warn(f"this type is {type(axA1)}")
495501
if config['volume']:
496502
if config['volume_panel'] == config['main_panel']:
497503
# ohlc and volume on same panel: move volume to secondary axes:
@@ -525,10 +531,10 @@ def plot( data, **kwargs ):
525531
collections = None
526532
if ptype == 'line':
527533
lw = config['_width_config']['line_width']
528-
axA1.plot(xdates, closes, color=config['linecolor'], linewidth=lw)
534+
pmarkevery = config['markevery']
535+
axA1.plot(xdates, closes, 'o', markevery=pmarkevery, ls='-', color=config['linecolor'], linewidth=lw, ) else:
529536
else:
530537
collections =_construct_mpf_collections(ptype,dates,xdates,opens,highs,lows,closes,volumes,config,style)
531-
532538
if ptype in VALID_PMOVE_TYPES:
533539
collections, calculated_values = collections
534540
volumes = calculated_values['volumes']
@@ -650,10 +656,35 @@ def plot( data, **kwargs ):
650656
tlines = [tlines,]
651657
for tline_item in tlines:
652658
line_collections.append(_construct_tline_collections(tline_item, dtix, dates, opens, highs, lows, closes))
653-
654-
for collection in line_collections:
655-
if collection is not None:
656-
axA1.add_collection(collection)
659+
### note
660+
# if config['addplot'] is not None:
661+
# for panid,row in panels.iterrows():
662+
# print(panid)
663+
# print("the value of min and max is ",miny,maxy)
664+
# print("type of row is ", type(row))
665+
# print("panid is ",panid)
666+
# print("row key is ",row.keys())
667+
# ax = row['axes']
668+
# line_collections = []
669+
# if (panid == 0):
670+
# line_collections.append(_construct_vline_collections(config['vlines'], dtix, miny, maxy))
671+
# else:
672+
# line_collections.append(_construct_vline_collections(config['vlines'], dtix, 200, 600))
673+
674+
# for collection in line_collections:
675+
# if collection is not None:
676+
# ax[0].add_collection(collection)
677+
if config['addplot'] is not None:
678+
for panid,row in panels.iterrows():
679+
ax = row['axes']
680+
print(dtix)
681+
print(config['vlines'])
682+
# _date_to_iloc
683+
ax[0].axvline(x=50.5,linestyle='--')
684+
else:
685+
for collection in line_collections:
686+
if collection is not None:
687+
axA1.add_collection(collection)
657688

658689
datalen = len(xdates)
659690
if config['volume']:

0 commit comments

Comments
 (0)