Python 增加Matplotlib中x轴标签的空间

Python 增加Matplotlib中x轴标签的空间,python,matplotlib,Python,Matplotlib,我正在绘图,但发现我需要增加图表下方的面积,这样我可以垂直地绘制标签,但字体大小不是很小。目前,我有: plt.figure(count_fig) fig, ax = plt.subplots() rects1 = ax.bar(ind, ratio_lst, width, color='r', linewidth=1, alpha=0.8, log=1) ax.set_ylabel('') ax.set_title('') ax.set_xticks(ind_width) ax.se

我正在绘图,但发现我需要增加图表下方的面积,这样我可以垂直地绘制标签,但字体大小不是很小。目前,我有:

plt.figure(count_fig) fig, ax = plt.subplots() 
rects1 = ax.bar(ind, ratio_lst, width, color='r', linewidth=1, alpha=0.8, log=1) 
ax.set_ylabel('') 
ax.set_title('') 
ax.set_xticks(ind_width) 
ax.set_xticklabels(labels_lst, rotation='vertical', fontsize=6)
目前它可以工作,但标签通常会从绘图边缘跑掉。

就可以了。您可以使用
bottom
关键字来获得绘图底部的良好位置

fig.subplots_adjust(bottom=0.2)

你能不能只做
fig.tight_layout()
来修复它?或者它对旋转的标签不起作用?@Sarment Nope-它不起作用。只是尝试了
fig.tight_layout()
,看起来它现在对旋转的标签起作用了!