2012-04-19 7 views
6

私はboxplotを使って非正規分布をプロットし、matplotlibのboxplot関数を使って外れ値を調べることに興味があります。matplotlibから外れ点を見つける:boxplot

プロットの他に、ボックスコードの外れ値として表示されるコード内のポイントの値を調べることに興味があります。 boxplotオブジェクトの下流のコードでこれらの値を抽出する方法はありますか?

答えて

12

2本の黒い線の上と下の点を意味しますか?

from pylab import * 
spread= rand(50) * 100 
center = ones(25) * 50 
flier_high = rand(10) * 100 + 100 
flier_low = rand(10) * -100 
data =concatenate((spread, center, flier_high, flier_low), 0) 
r = boxplot(data) 

enter image description here

ストア箱ひげからの戻りdictの、そしてあなたは、たとえば、そこからすべての情報を取得することができます。

top_points = r["fliers"][0].get_data()[1] 
bottom_points = r["fliers"][2].get_data()[1] 
plot(np.ones(len(top_points)), top_points, "+") 
plot(np.ones(len(bottom_points)), bottom_points, "+") 

enter image description here

関連する問題