2

当我在 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')

第一个情节的xlabel文本在第二个情节下丢失了。这是情节:

在此处输入图像描述

你可以看到“P”的顶部伸出来。如何在xlabel不发生这种情况的情况下为子图提供 s?

4

2 回答 2

4

您可以使用plt.tight_layout()调整子图,使 x-label 可见。

于 2013-08-09T17:19:46.657 回答
2

As an alternative to @Molly's excellent suggestion a more manual approach is to use

plt.subplots_adjust(hspace=0.1)

Since your x axes are all the same, I would suggest setting hspace=0.0 and removing the x axis labels (use plt.set_xticklabels([])). This saves space and reduces the amount of repeated information.

于 2013-08-09T20:10:11.697 回答