2015-03-02 46 views
0

當我試圖調整boxplot晶須長度時,我收到一個錯綜複雜的錯誤 - 我想有晶須從第5百分位數延伸到第95百分位值,使用kwarg whis = [5,95]。當我這樣做,我得到以下錯誤(複製整個回溯):蟒蛇:錯誤設置boxplot晶須邊界

> Traceback (most recent call last): 
> File "boxplot_snoho_bc.py", line 125, in <module> 
>  main() 
> File "boxplot_snoho_bc.py", line 64, in main 
>  bp = boxplot(data[0], positions = [1], widths = 0.6, whis = [5,95]) 
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2143, in boxplot 
>  ret = ax.boxplot(x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap) 
> File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 5545, in 
> boxplot 
>  wisk_hi = np.compress(d <= hi_val , d) 
> ValueError: operands could not be broadcast together with shapes (10) (42) 

我從其他線程和幫助文檔的理解是,這是正確的語法,但我是新來的蟒蛇很可能得到問題的話...

爲了清楚起見,這裏是導致錯誤的命令:

bp = boxplot(data[0], positions = [1], widths = 0.6, whis = [5,95])

data是8×10陣列numpy的;我一次只繪製一個盒子。以下是陣列的外觀:

print data

[[ 40.66 33.53 30.56 30.83 11.8 60.91 11.91 10.74 23.97 11. ]

[ 16.19 85.69 206.25 27.16 29.22 41.69 16.44 10.41 477.75 23.95]

[ 1651. 192. 16.02 29.91 14.95 123.38 31.22 11.08 29.5 16.03]

[ 132.5 874.5 12.51 41.5 68.25 60.22 36.91 12.27 58.84 28.33]

[ 145.5 26.95 25.2 33.88 44.78 40.16 16.78 18.95 36.03 16.05]

[ 18.89 82.94 83.56 344. 118.94 49.62 23.23 25.89 2072. 90.56]

[ 221.38 22.69 35.28 25.08 25.16 41.84 16.77 14.16 12.77 15.27]

[ 32.03 1634. 34.59 140.12 61.22 32.53 24.55 20.06 30.97 27.14]]

回答

0

問題已解決。令人尷尬的是,這是matplotlib的版本問題(至少需要1.4.0版本)。