3
3
import matplotlib .colors as mcolors
4
4
import matplotlib .axes as mpl_axes
5
5
import matplotlib .figure as mpl_fig
6
+ import matplotlib .ticker as mtk
6
7
import pandas as pd
7
8
import numpy as np
8
9
import copy
@@ -471,6 +472,13 @@ def plot( data, **kwargs ):
471
472
if collection is not None :
472
473
axA1 .add_collection (collection )
473
474
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
+
474
482
datalen = len (xdates )
475
483
if config ['volume' ]:
476
484
vup ,vdown = style ['marketcolors' ]['volume' ].values ()
@@ -488,13 +496,6 @@ def plot( data, **kwargs ):
488
496
maxy = 1.1 * np .nanmax (volumes )
489
497
volumeAxes .set_ylim ( miny , maxy )
490
498
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
-
498
499
addplot = config ['addplot' ]
499
500
if addplot is not None and ptype not in VALID_PMOVE_TYPES :
500
501
# NOTE: If in external_axes_mode, then all code relating
@@ -609,9 +610,14 @@ def plot( data, **kwargs ):
609
610
axA1 .set_ylabel (config ['ylabel' ])
610
611
611
612
if config ['volume' ]:
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 )
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 = ''
615
621
if len (offset ) > 0 :
616
622
offset = (' x ' + offset )
617
623
if config ['ylabel_lower' ] is None :
@@ -621,9 +627,6 @@ def plot( data, **kwargs ):
621
627
offset = '\n ' + offset
622
628
vol_label = config ['ylabel_lower' ] + offset
623
629
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 )
627
630
628
631
if config ['title' ] is not None :
629
632
if config ['tight_layout' ]:
0 commit comments