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