Skip to content

Commit eee081c

Browse files
merge changes from Juan Badia Payno
2 parents f1195f0 + 14304a8 commit eee081c

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/mplfinance/plotting.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,10 @@ 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' : _fill_between_validator },
308-
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))},
309311
'tight_layout' : { 'Default' : False,
310312
'Description' : 'True|False implement tight layout (minimal padding around Figure)'+
311313
' (see also `scale_padding` kwarg)',
@@ -703,24 +705,30 @@ def plot( data, **kwargs ):
703705
# fill_between is NOT supported for external_axes_mode
704706
# (caller can easily call ax.fill_between() themselves).
705707
if config['fill_between'] is not None and not external_axes_mode:
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']
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)
720728
fb['x'] = xdates
721729
ax = panels.at[panid,'axes'][0]
722730
ax.fill_between(**fb)
723-
731+
724732
# put the primary axis on one side,
725733
# and the twinx() on the "other" side:
726734
if not external_axes_mode:

0 commit comments

Comments
 (0)