@@ -194,6 +194,10 @@ def _valid_plot_kwargs():
194
194
'axtitle' : { 'Default' : None , # Axes Title (subplot title)
195
195
'Description' : 'Axes Title (subplot title)' ,
196
196
'Validator' : lambda value : isinstance (value ,(str ,dict )) },
197
+
198
+ 'xlabel' : { 'Default' : None , # x-axis label
199
+ 'Description' : 'label for x-axis of plot' ,
200
+ 'Validator' : lambda value : isinstance (value ,str ) },
197
201
198
202
'ylabel' : { 'Default' : 'Price' , # y-axis label
199
203
'Description' : 'label for y-axis of main plot' ,
@@ -675,10 +679,12 @@ def plot( data, **kwargs ):
675
679
676
680
xrotation = config ['xrotation' ]
677
681
if not external_axes_mode :
678
- _set_ticks_on_bottom_panel_only (panels ,formatter ,rotation = xrotation )
682
+ _set_ticks_on_bottom_panel_only (panels ,formatter ,rotation = xrotation ,
683
+ xlabel = config ['xlabel' ])
679
684
else :
680
685
axA1 .tick_params (axis = 'x' ,rotation = xrotation )
681
686
axA1 .xaxis .set_major_formatter (formatter )
687
+ axA1 .set_xlabel (config ['xlabel' ])
682
688
683
689
ysd = config ['yscale' ]
684
690
if isinstance (ysd ,dict ):
@@ -727,8 +733,8 @@ def plot( data, **kwargs ):
727
733
elif panid == 'lower' : panid = 1 # for backwards compatibility
728
734
if apdict ['y_on_right' ] is not None :
729
735
panels .at [panid ,'y_on_right' ] = apdict ['y_on_right' ]
730
-
731
736
aptype = apdict ['type' ]
737
+
732
738
if aptype == 'ohlc' or aptype == 'candle' :
733
739
ax = _addplot_collections (panid ,panels ,apdict ,xdates ,config )
734
740
_addplot_apply_supplements (ax ,apdict ,xdates )
@@ -1096,6 +1102,11 @@ def _addplot_columns(panid,panels,ydata,apdict,xdates,config):
1096
1102
def _addplot_apply_supplements (ax ,apdict ,xdates ):
1097
1103
if (apdict ['ylabel' ] is not None ):
1098
1104
ax .set_ylabel (apdict ['ylabel' ])
1105
+ # Note that xlabel is NOT supported for addplot. This is because
1106
+ # in Panels Mode, there is only one xlabel (on the bottom axes)
1107
+ # which is handled by the `xlabel` kwarg of `mpf.plot()`,
1108
+ # whereas in External Axes Mode, users can call `Axes.set_xlabel()` on
1109
+ # the axes object of their choice.
1099
1110
if apdict ['ylim' ] is not None :
1100
1111
ax .set_ylim (apdict ['ylim' ][0 ],apdict ['ylim' ][1 ])
1101
1112
if apdict ['title' ] is not None :
0 commit comments