4

我的问题在于 matplotlib,更准确地说是 subplot2grid :xlabels 只是拒绝出现在前 2 个条形图上(在屏幕截图之后。)

xlabels 拒绝显示 **

下面的代码:

**

fig = plt.figure(figsize=(12,15), dpi=1600) 

fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)

ax1 = plt.subplot2grid((3,2),(0,0))
t_mois.sort('mois').plot(kind='bar', x='mois', y='count', legend=False, ax=ax1, alpha=alpha_bar_chart)
ax1.set_xlabel('plot 1 x-label')

ax2 = plt.subplot2grid((3,2),(0,1))
t_semaine.sort('jours_semaine').plot(kind='bar', x='jours_semaine', y='count', legend=False, ax=ax2, alpha=alpha_bar_chart)
plt.setp(ax2.get_xticklabels(), visible=True)
ax2.set_xlabel('plot 2 x-label')

ax3 = plt.subplot2grid((3,2),(1,0), colspan=2)
t_jours_mois.sort('jours_mois').plot(kind='bar', x='jours_mois', y='count', legend=False, ax=ax3)

ax4 = plt.subplot2grid((3,2),(2,0), colspan=2)
t_jour_annee.sort('jours_annee').plot(kind='bar', x='jours_annee', y='count', legend=False, ax=ax4)

plt.tight_layout()
plt.show()

我已经尝试了几件事(例如更改网格大小,手动设置它们,在绘图之间添加空格......)但没有成功。相比之下,当我在单独的网格或控制台中绘制它时,xlabels 会自然地出现。

有什么猜测吗?

非常感谢

注意:我正在使用带有 Python 3 内核的 Jupyter(最新版本的 Ipython Notebook)。

4

0 回答 0