y_label 在 matplotlib 中被截断

y_label in matplotlib is cutoff

我正在尝试绘制此图:

有了这个 :

r_bt.longueur_groupby_section.plot(kind='barh',ylabel='Nombre de clients',xlabel='type de cable',title='longueur de conducteur en fonction de la section')
plt.legend()
plt.show()

但是ylabel被截断了.. 我尝试了 plt.autoscale() 但它不起作用..

有人知道吗?

您可以使用 subplots_adjust() 函数调整 matplotlib 图形周围的间距:

import matplotlib.pyplot as plt
plt.plot(whatever)
plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1)

根据需要增加左值