I want my x axis has the label like this format
0 1 2 3 4 5 Xlabel
but I try code below it result me in 2 lines
self.axes.
I use the solution provided by @JoeKington, with the extension of having label font properties imposed on the text produced by ax.annotate(...).
This is important when axis labels are formatted differently than other text.
import matplotlib.pyplot as plt
import matplotlib as mpl
ticklabelpad = mpl.rcParams['xtick.major.pad']
fig, ax = plt.subplots()
ax.set_xlim([0, 5])
dx_in_points = 5
fontproperties = ax.xaxis.get_label().get_fontproperties()
ax.annotate('XLabel', xy=(1,0), xytext=(dx_in_points, -ticklabelpad), ha='left', va='top',
xycoords='axes fraction', textcoords='offset points', fontproperties=fontproperties)
plt.show()