简体   繁体   English

如何使用matplotlib减少图和xticks之间的间距?

[英]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. 通过箭头,我想减小plot和xticks之间的间距。 Thanks in advance for the help. 先谢谢您的帮助。

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'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM