2016-04-12 5 views
14

これは簡単な質問のようですが、私はしばらく検索していて、答えが見つからないようです。それはまた、これらのパッケージの標準的な部分でなければならない何かのようです。 seabornの分布図の間に統計的アノテーションを含める標準的な方法があるかどうかは誰にも分かりますか?matplotlib/seabornプロットに統計アノテーション(星またはp値)を挿入するにはどうすればよいですか?

たとえば、2つのボックスまたはスワンプロットの間ですか? Seabornボックスプロットに統計的な注釈を追加する方法をここで

Example: the yellow distribution is significantly different than the others (by wilcoxon - how can i display that visually?

+1

Axes.textまたはAxes.annotate –

+0

比較するRの例がありますか? (MVCE!コードに共通のデータセットと取得したいものの説明を教えてください) – cphlewis

+0

私が信じていることの良い例https://github.com/jbmouret/matplotlib_for_papers – thescoop

答えて

18

import seaborn as sns, matplotlib.pyplot as plt 

tips = sns.load_dataset("tips") 
sns.boxplot(x="day", y="total_bill", data=tips, palette="PRGn") 

# statistical annotation 
x1, x2 = 2, 3 # columns 'Sat' and 'Sun' (first column: 0, see plt.xticks()) 
y, h, col = tips['total_bill'].max() + 2, 2, 'k' 
plt.plot([x1, x1, x2, x2], [y, y+h, y+h, y], lw=1.5, c=col) 
plt.text((x1+x2)*.5, y+h, "ns", ha='center', va='bottom', color=col) 

plt.show() 

そして、ここでの結果:あなたは基礎となるmatplotlibのAxesオブジェクトと使用を引き出すために必要 box plot annotated

関連する問題