当使用histtype='stepfilled'和log=True选项时,我在matplotlib中显示直方图遇到了问题。 我在matplotlib版本1.1.0中遇到了这个问题,并发现在版本1.2.0中仍然存在。
不幸的是,我没有发布图像的权利,但您可以使用此简单代码检查此行为:
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mu, sigma = 200, 25
x = mu + sigma*np.random.randn(10000)
n, bins, patches = plt.hist(x, 50, normed=1, histtype='bar',log=True)
plt.savefig("test1.png")
plt.clf()
n, bins, patches = plt.hist(x, 50, normed=1, histtype='stepfilled',log=True)
plt.savefig("test2.png")
第一张图是正确的,而在第二种情况下,使用选项histtype='stepfilled'而不是'bar',则无法显示。 有人知道原因吗?