2013-04-22 83 views

回答

7

注意:下面的解決方案適用於matplotlib版本< 1.3.1。


使用


import numpy as np 
import matplotlib.pyplot as plt 
mu, sigma = 100, 15 
fig, ax = plt.subplots() 
x = mu + sigma * np.random.randn(10000) 
ax.set_yscale('log', basey=2) 
n, bins, histpatches = ax.hist(x, 50, facecolor='green', alpha=0.75) 
plt.show() 

enter image description here

+1

@twch:感謝您提出修改建議。在matplotlib版本1.3.1中似乎有一個迴歸,導致只繪製條的頂部。不幸的是,我必須恢復編輯(使用'log = True'),因爲它還會將y軸縮放比例改爲以10爲底的日誌,而不是日誌基數2,這是SO帖子試圖解決的主要問題。 – unutbu 2014-02-04 18:25:47

+0

請將此類錯誤報告爲錯誤。 – tacaswell 2014-07-02 02:34:00

+0

而且它似乎是固定在主人身上的,它很快就會變成1.4.0。 – tacaswell 2014-07-02 02:42:20