子图隐藏 xlabel

Roy*_*ith 2 matplotlib

当我在 IPython 中运行它时:

r = (100, 300)
b = 100
plt.figure(figsize=(8, 6))
plt.subplot(3,1,1)
plt.xlabel('Picker time (ms)')
plt.hist(sequential['X0'], range=r, bins=b, color='blue')
plt.subplot(3,1,2)
plt.hist(stateful['X0'], range=r, bins=b, color='green')
plt.subplot(3,1,3)
plt.hist(standard['X0'], range=r, bins=b, color='red')
Run Code Online (Sandbox Code Playgroud)

第一个情节的文本xlabel在第二个情节下消失了。情节如下:

在此输入图像描述

你只能看到“P”的顶部伸出来。如何xlabel为子图提供 s 而不会发生这种情况?

Mol*_*lly 5

您可以使用plt.tight_layout()来调整子图,以便 x 标签可见。