Skip to content

Commit 768e398

Browse files
Merge pull request #7 from DanielGoldfarb/master
fix axes spacing, and display validator upon invalid kwarg
2 parents 289a0ad + bc7edf4 commit 768e398

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ mpf.plot(iday,type='candle')
328328

329329

330330
---
331-
In the plot below, we see **what would happend if ` no_xgaps ` did NOT** default to `True` for intraday data involving two or more days.
331+
In the plot below, we see **what would happen if ` no_xgaps ` did NOT** default to `True` for intraday data involving two or more days.
332332

333333

334334
```python
@@ -553,6 +553,6 @@ With this new ` mplfinance ` package installed, in addition to the new API, user
553553
where `<method>` indicates the method you want to import, for example:
554554

555555
```python
556-
from mplfinance.original_flavor import candlestick_ohlc\
556+
from mplfinance.original_flavor import candlestick_ohlc
557557
```
558558

src/mplfinance/plotting.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def _mav_validator(mav_value):
127127
'figscale' : { 'Default' : 0.75, # scale base figure size (11" x 8.5") up or down.
128128

129129
'Implemented' : True,
130-
'Validator' : lambda value: isinstance(value,float) },
130+
'Validator' : lambda value: isinstance(value,float) or isinstance(value,int) },
131131

132132
'autofmt_xdate':{ 'Default' : False,
133133

@@ -170,7 +170,9 @@ def _process_kwargs( kwargs ):
170170
else:
171171
value = kwargs[key]
172172
if not vkwargs[key]['Validator'](value):
173-
raise ValueError('kwarg "'+key+'" with invalid value: "'+str(value)+'"')
173+
import inspect
174+
v = inspect.getsource(vkwargs[key]['Validator']).strip()
175+
raise ValueError('kwarg "'+key+'" with invalid value: "'+str(value)+'"\n '+v)
174176
# if we are here, then kwarg is valid as far as we can tell;
175177
# replace the appropriate value in config:
176178
config[key] = value
@@ -205,15 +207,14 @@ def plot( data, **kwargs ):
205207
if config['volume']:
206208
if volumes is None:
207209
raise ValueError('Request for volume, but NO volume data.')
208-
ax1 = fig.add_axes( [0.05, 0.25, 0.9, 0.7] )
209-
ax2 = fig.add_axes( [0.05, 0.05, 0.9, 0.2], sharex=ax1 )
210+
ax1 = fig.add_axes( [0.15, 0.38, 0.70, 0.50] )
211+
ax2 = fig.add_axes( [0.15, 0.18, 0.70, 0.20], sharex=ax1 )
210212
else:
211-
ax1 = fig.add_axes( [0.05, 0.05, 0.9, 0.9] )
213+
ax1 = fig.add_axes( [0.15, 0.18, 0.70, 0.70] )
212214
ax2 = None
213215

214216
avg_days_between_points = (dates[-1] - dates[0]) / float(len(dates))
215217

216-
217218
# Default logic for 'no_xgaps': True for intraday data spanning 2 or more days, else False
218219
# Caller provided 'no_xgaps' kwarg OVERRIDES default logic.
219220

0 commit comments

Comments
 (0)