Skip to content

Commit 6e10238

Browse files
restore plotting.py after backend investigations
1 parent 2c88663 commit 6e10238

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/mplfinance/plotting.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import matplotlib.colors as mcolors
44
import matplotlib.axes as mpl_axes
55
import matplotlib.figure as mpl_fig
6-
import matplotlib.ticker as mtk
76
import pandas as pd
87
import numpy as np
98
import copy
@@ -472,13 +471,6 @@ def plot( data, **kwargs ):
472471
if collection is not None:
473472
axA1.add_collection(collection)
474473

475-
xrotation = config['xrotation']
476-
if not external_axes_mode:
477-
_set_ticks_on_bottom_panel_only(panels,formatter,rotation=xrotation)
478-
else:
479-
axA1.tick_params(axis='x',rotation=xrotation)
480-
axA1.xaxis.set_major_formatter(formatter)
481-
482474
datalen = len(xdates)
483475
if config['volume']:
484476
vup,vdown = style['marketcolors']['volume'].values()
@@ -496,6 +488,13 @@ def plot( data, **kwargs ):
496488
maxy = 1.1 * np.nanmax(volumes)
497489
volumeAxes.set_ylim( miny, maxy )
498490

491+
xrotation = config['xrotation']
492+
if not external_axes_mode:
493+
_set_ticks_on_bottom_panel_only(panels,formatter,rotation=xrotation)
494+
else:
495+
axA1.tick_params(axis='x',rotation=xrotation)
496+
axA1.xaxis.set_major_formatter(formatter)
497+
499498
addplot = config['addplot']
500499
if addplot is not None and ptype not in VALID_PMOVE_TYPES:
501500
# NOTE: If in external_axes_mode, then all code relating
@@ -610,14 +609,9 @@ def plot( data, **kwargs ):
610609
axA1.set_ylabel(config['ylabel'])
611610

612611
if config['volume']:
613-
if external_axes_mode:
614-
volumeAxes.tick_params(axis='x',rotation=xrotation)
615-
volumeAxes.xaxis.set_major_formatter(formatter)
616-
#volumeAxes.figure.canvas.draw() # This is needed to calculate offset
617-
volumeAxes.yaxis.set_major_formatter(mtk.FormatStrFormatter('%.0e'))
618-
#offset = volumeAxes.yaxis.get_major_formatter().get_offset()
619-
#volumeAxes.yaxis.offsetText.set_visible(False)
620-
offset = ''
612+
volumeAxes.figure.canvas.draw() # This is needed to calculate offset
613+
offset = volumeAxes.yaxis.get_major_formatter().get_offset()
614+
volumeAxes.yaxis.offsetText.set_visible(False)
621615
if len(offset) > 0:
622616
offset = (' x '+offset)
623617
if config['ylabel_lower'] is None:
@@ -627,6 +621,9 @@ def plot( data, **kwargs ):
627621
offset = '\n'+offset
628622
vol_label = config['ylabel_lower'] + offset
629623
volumeAxes.set_ylabel(vol_label)
624+
if external_axes_mode:
625+
volumeAxes.tick_params(axis='x',rotation=xrotation)
626+
volumeAxes.xaxis.set_major_formatter(formatter)
630627

631628
if config['title'] is not None:
632629
if config['tight_layout']:

0 commit comments

Comments
 (0)