【发布时间】:2012-11-27 11:40:07
【问题描述】:
当同时使用选项 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',没有。 有人知道吗?
【问题讨论】:
标签: matplotlib histogram