【发布时间】:2019-10-15 04:29:55
【问题描述】:
我完成了对数据的分析,并希望使用t-test_ind 来证明它们具有统计显着性。但是,除了 (How does one insert statistical annotations (stars or p-values) into matplotlib / seaborn plots?) 中引用的内容之外,我没有发现任何功能可以显示这一点:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
from statannot import add_stat_annotation
ax = sns.barplot(x=x, y=y, order=order)
add_stat_annotation(ax, data=df, x=x, y=y,
boxPairList=[(order[0], order[1]), (order[0], order[2])],
test='t-test_ind',
textFormat='star',
loc='outside')
但是,使用这种方法时,每当我尝试使用 plt.savefig() 保存绘图时,使用 add_stat_annotation 的附加意义都会被丢弃(matplotlib 似乎无法识别添加的注释)。使用 loc='inside' 选项会弄乱我的情节,所以它不是一个真正的选项。
因此,我想问是否有一些更简单的方法可以直接在 matplotlib/seaborn 中添加重要性,或者您是否可以 plt.savefig() 有足够的边框/填充来包含所有内容。
【问题讨论】:
标签: python matplotlib statistics seaborn