我的MCVE:
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
#normal sample
mu, sigma = 100, 15
x = mu + sigma*np.random.randn(10000)
#histogram
n, bins, patches = plt.hist(x, 50)
plt.axis([40, 160, 0, 800])
n2, bins2, patches2 = plt.hist(x,50,log=True)
n1 = np.log(n)
为什么n2
与{log = True
按对数比例缩放。。但它没有。那它在做什么呢?bins2
和bins1 = np.log(bins)
也会发生同样的情况。在
编辑 这个
^{pr2}$给了我
然后通过做
histsq = np.sqrt(np.log(hist))
plt.bar(np.delete(bin_edges,len(bin_edges)-1),histsq,nwidth)
plt.show()
我得到
当您设置log=True时,直方图轴(不是返回参数)以log-scale为单位。对于log=True和log=False,返回参数(n,bins),即容器的值和容器的边缘是相同的。这意味着n==n2和bins==bins2都是真的。在
请参阅下面的代码以查看这是否正确
会回来的
^{pr2}$相关问题 更多 >
编程相关推荐