Skip to content

Commit bdbd4ef

Browse files
simplify axisoff per #48 (comment)
1 parent 6c62bf0 commit bdbd4ef

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/mplfinance/plotting.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,7 @@ def _valid_plot_kwargs():
198198
'xrotation' : { 'Default' : 45,
199199
'Validator' : lambda value: isinstance(value,(int,float)) },
200200

201-
'axesoff' : { 'Default' : False,
202-
'Validator' : lambda value: isinstance(value,bool) },
203-
204-
'axesoffdark' : { 'Default' : False,
201+
'axisoff' : { 'Default' : False,
205202
'Validator' : lambda value: isinstance(value,bool) },
206203

207204
'closefig' : { 'Default' : 'auto',
@@ -628,19 +625,24 @@ def plot( data, **kwargs ):
628625
# For now, for backwards compatibility, we flatten axes list:
629626
axlist = [ax for axes in panels['axes'] for ax in axes]
630627

631-
if config['axesoffdark']: fig.patch.set_facecolor('black')
632-
if config['axesoff']: fig.patch.set_visible(False)
633-
if config['axesoffdark'] or config['axesoff']:
628+
if config['axisoff']:
634629
for ax in axlist:
635630
ax.set_xlim(xdates[0],xdates[-1])
636631
ax.set_axis_off()
637632

638633
if config['savefig'] is not None:
639634
save = config['savefig']
640635
if isinstance(save,dict):
641-
plt.savefig(**save)
636+
# Expand to fill chart if axisoff
637+
if config['axisoff'] and 'bbox_inches' not in save:
638+
plt.savefig(**save,bbox_inches='tight')
639+
else:
640+
plt.savefig(**save)
642641
else:
643-
plt.savefig(save)
642+
if config['axisoff']:
643+
plt.savefig(save,bbox_inches='tight')
644+
else:
645+
plt.savefig(save)
644646
if config['closefig']: # True or 'auto'
645647
plt.close(fig)
646648
elif not config['returnfig']:

0 commit comments

Comments
 (0)