@@ -185,8 +185,8 @@ def _valid_plot_kwargs():
185
185
'Description' : 'Axes Title (subplot title)' ,
186
186
'Validator' : lambda value : isinstance (value ,(str ,dict )) },
187
187
188
- 'xlabel' : { 'Default' : 'Date' , # x-axis label
189
- 'Description' : 'label for x-axis of main plot' ,
188
+ 'xlabel' : { 'Default' : None , # x-axis label
189
+ 'Description' : 'label for x-axis of plot' ,
190
190
'Validator' : lambda value : isinstance (value ,str ) },
191
191
192
192
'ylabel' : { 'Default' : 'Price' , # y-axis label
@@ -653,10 +653,12 @@ def plot( data, **kwargs ):
653
653
654
654
xrotation = config ['xrotation' ]
655
655
if not external_axes_mode :
656
- _set_ticks_on_bottom_panel_only (panels ,formatter ,rotation = xrotation )
656
+ _set_ticks_on_bottom_panel_only (panels ,formatter ,rotation = xrotation ,
657
+ xlabel = config ['xlabel' ])
657
658
else :
658
659
axA1 .tick_params (axis = 'x' ,rotation = xrotation )
659
660
axA1 .xaxis .set_major_formatter (formatter )
661
+ axA1 .set_xlabel (config ['xlabel' ])
660
662
661
663
ysd = config ['yscale' ]
662
664
if isinstance (ysd ,dict ):
@@ -705,7 +707,13 @@ def plot( data, **kwargs ):
705
707
elif panid == 'lower' : panid = 1 # for backwards compatibility
706
708
if apdict ['y_on_right' ] is not None :
707
709
panels .at [panid ,'y_on_right' ] = apdict ['y_on_right' ]
708
-
710
+ if apdict ['xlabel' ] is not None :
711
+ apdict ['xlabel' ] = None # set to None so `_addplot_apply_supplements()` won't apply it.
712
+ warnings .warn ('\n \n ================================================================= ' +
713
+ '\n \n WARNING: make_addplot `xlabel` IGNORED in Panels mode.' +
714
+ '\n Use `mpf.plot(...,xlabel=)` instead.' +
715
+ '\n \n ================================================================ ' ,
716
+ category = UserWarning )
709
717
aptype = apdict ['type' ]
710
718
if aptype == 'ohlc' or aptype == 'candle' :
711
719
ax = _addplot_collections (panid ,panels ,apdict ,xdates ,config )
@@ -783,7 +791,6 @@ def plot( data, **kwargs ):
783
791
# working in `addplot`).
784
792
785
793
axA1 .set_ylabel (config ['ylabel' ])
786
- axA1 .set_xlabel (config ['xlabel' ])
787
794
788
795
if config ['volume' ]:
789
796
if external_axes_mode :
@@ -1250,6 +1257,10 @@ def _valid_addplot_kwargs():
1250
1257
'Description' : 'label for y-axis (for this addplot)' ,
1251
1258
'Validator' : lambda value : isinstance (value ,str ) },
1252
1259
1260
+ 'xlabel' : { 'Default' : None , # x-axis label
1261
+ 'Description' : 'x-axis label (for addplot ONLY when in external axes mode)' ,
1262
+ 'Validator' : lambda value : isinstance (value ,str ) },
1263
+
1253
1264
'ylim' : {'Default' : None ,
1254
1265
'Description' : 'Limits for addplot y-axis as tuple (min,max), i.e. (bottom,top)' ,
1255
1266
'Validator' : lambda value : isinstance (value , (list ,tuple )) and len (value ) == 2
0 commit comments