Skip to content

Commit dbc5b11

Browse files
some cleanup; make axisoff and tight_layout independent of each other
1 parent cfb787c commit dbc5b11

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/mplfinance/plotting.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,10 @@ def plot( data, **kwargs ):
349349

350350
avg_dist_between_points = (xdates[-1] - xdates[0]) / float(len(xdates))
351351
if not config['tight_layout']:
352-
#print('plot: xdates[-1]=',xdates[-1])
353-
#print('plot: xdates[ 0]=',xdates[ 0])
354-
#print('plot: len(xdates)=',len(xdates))
355-
#print('plot: avg_dist_between_points =',avg_dist_between_points)
356352
minx = xdates[0] - avg_dist_between_points
357353
maxx = xdates[-1] + avg_dist_between_points
358354
else:
359-
minx = xdates[0] - (0.45 * avg_dist_between_points)
355+
minx = xdates[0] - (0.45 * avg_dist_between_points)
360356
maxx = xdates[-1] + (0.45 * avg_dist_between_points)
361357

362358
if len(xdates) == 1: # kludge special case
@@ -371,11 +367,6 @@ def plot( data, **kwargs ):
371367

372368
miny = np.nanmin(_lows)
373369
maxy = np.nanmax(_highs)
374-
#if len(xdates) > 1:
375-
# stdy = (stat.stdev(_lows) + stat.stdev(_highs)) / 2.0
376-
#else: # kludge special case
377-
# stdy = 0.02 * math.fabs(maxy - miny)
378-
# print('minx,miny,maxx,maxy,stdy=',minx,miny,maxx,maxy,stdy)
379370

380371
if config['set_ylim'] is not None:
381372
axA1.set_ylim(config['set_ylim'][0], config['set_ylim'][1])
@@ -397,7 +388,8 @@ def plot( data, **kwargs ):
397388
if config['volume']:
398389
retdict[prekey+'_volumes'] = volumes
399390
if mavgs is not None:
400-
for i in range(0, len(mavgs)):
391+
# This is WRONG! Returning the same mavprices for all mavgs ??!
392+
for i in range(0, len(mavgs)):
401393
retdict['mav' + str(mavgs[i])] = mavprices
402394
retdict['minx'] = minx
403395
retdict['maxx'] = maxx
@@ -669,19 +661,17 @@ def plot( data, **kwargs ):
669661

670662
if config['axisoff']:
671663
for ax in axlist:
672-
ax.set_xlim(xdates[0],xdates[-1])
673664
ax.set_axis_off()
674665

675666
if config['savefig'] is not None:
676667
save = config['savefig']
677668
if isinstance(save,dict):
678-
# Expand to fill chart if axisoff
679-
if config['axisoff'] and 'bbox_inches' not in save:
669+
if config['tight_layout'] and 'bbox_inches' not in save:
680670
plt.savefig(**save,bbox_inches='tight')
681671
else:
682672
plt.savefig(**save)
683673
else:
684-
if config['axisoff']:
674+
if config['tight_layout']:
685675
plt.savefig(save,bbox_inches='tight')
686676
else:
687677
plt.savefig(save)

0 commit comments

Comments
 (0)