Skip to content

Commit f02ca53

Browse files
restore updated fill_between
1 parent eee081c commit f02ca53

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

src/mplfinance/plotting.py

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,8 @@ def _valid_plot_kwargs():
304304
'Description' : 'fill between specification as y-value, or sequence of'+
305305
' y-values, or dict containing key "y1" plus any additional'+
306306
' kwargs for `fill_between()`',
307-
'Validator' : lambda value: _num_or_seq_of_num(value) or
308-
(isinstance(value,dict) and 'y1' in value and
309-
_num_or_seq_of_num(value['y1'])) or
310-
isinstance(value,(list,tuple))},
307+
'Validator' : _fill_between_validator },
308+
311309
'tight_layout' : { 'Default' : False,
312310
'Description' : 'True|False implement tight layout (minimal padding around Figure)'+
313311
' (see also `scale_padding` kwarg)',
@@ -705,30 +703,24 @@ def plot( data, **kwargs ):
705703
# fill_between is NOT supported for external_axes_mode
706704
# (caller can easily call ax.fill_between() themselves).
707705
if config['fill_between'] is not None and not external_axes_mode:
708-
fb = config['fill_between']
709-
panid = config['main_panel']
710-
if isinstance(fb,list):
711-
for element in fb:
712-
if 'panel' in element:
713-
panind = element['panel']
714-
del element['panel']
715-
716-
element['x'] = xdates
717-
ax = panels.at[panid,'axes'][0]
718-
ax.fill_between(**element)
719-
else:
720-
if isinstance(fb,dict):
721-
if 'x' in fb:
722-
raise ValueError('fill_between dict may not contain `x`')
723-
if 'panel' in fb:
724-
panid = fb['panel']
725-
del fb['panel']
726-
else:
727-
fb = dict(y1=fb)
706+
fblist = config['fill_between']
707+
panid = config['main_panel']
708+
if _num_or_seq_of_num(fblist):
709+
fblist = [dict(y1=fblist),]
710+
elif isinstance(fblist,dict):
711+
fblist = [fblist,]
712+
if not _list_of_dict(fblist):
713+
raise TypeError('Bad type for `fill_between` specifier.')
714+
for fb in fblist:
715+
if 'x' in fb:
716+
raise ValueError('fill_between dict may not contain `x`')
717+
if 'panel' in fb:
718+
panid = fb['panel']
719+
del fb['panel']
728720
fb['x'] = xdates
729721
ax = panels.at[panid,'axes'][0]
730722
ax.fill_between(**fb)
731-
723+
732724
# put the primary axis on one side,
733725
# and the twinx() on the "other" side:
734726
if not external_axes_mode:

0 commit comments

Comments
 (0)