@@ -194,6 +194,10 @@ def _valid_plot_kwargs():
194194 'axtitle' : { 'Default' : None , # Axes Title (subplot title)
195195 'Description' : 'Axes Title (subplot title)' ,
196196 '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 ) },
197201
198202 'ylabel' : { 'Default' : 'Price' , # y-axis label
199203 'Description' : 'label for y-axis of main plot' ,
@@ -675,10 +679,12 @@ def plot( data, **kwargs ):
675679
676680 xrotation = config ['xrotation' ]
677681 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' ])
679684 else :
680685 axA1 .tick_params (axis = 'x' ,rotation = xrotation )
681686 axA1 .xaxis .set_major_formatter (formatter )
687+ axA1 .set_xlabel (config ['xlabel' ])
682688
683689 ysd = config ['yscale' ]
684690 if isinstance (ysd ,dict ):
@@ -727,8 +733,8 @@ def plot( data, **kwargs ):
727733 elif panid == 'lower' : panid = 1 # for backwards compatibility
728734 if apdict ['y_on_right' ] is not None :
729735 panels .at [panid ,'y_on_right' ] = apdict ['y_on_right' ]
730-
731736 aptype = apdict ['type' ]
737+
732738 if aptype == 'ohlc' or aptype == 'candle' :
733739 ax = _addplot_collections (panid ,panels ,apdict ,xdates ,config )
734740 _addplot_apply_supplements (ax ,apdict ,xdates )
@@ -1096,6 +1102,11 @@ def _addplot_columns(panid,panels,ydata,apdict,xdates,config):
10961102def _addplot_apply_supplements (ax ,apdict ,xdates ):
10971103 if (apdict ['ylabel' ] is not None ):
10981104 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.
10991110 if apdict ['ylim' ] is not None :
11001111 ax .set_ylim (apdict ['ylim' ][0 ],apdict ['ylim' ][1 ])
11011112 if apdict ['title' ] is not None :
0 commit comments