Q:

How to reduce spacing between plot and xticks using matplotlib?

As shown in the figure

by the arrows, I'd like to decrease the spacing between plot and xticks.
Thanks in advance for the help.

A:

Here are three ways to set the distance between ticklabels and the axis:
ax.tick_params(axis='x', pad=10)
ax.xaxis.labelpad = 10
plt.xlabel("your labels go here", labelpad=10)

And here's another one:
from matplotlib import rcParams
rcParams['xtick.major.pad']='8'

