# 【2.5.4.2】statannot--boxplot显著性标注

## 一、安装：

The latest stable release can be installed from PyPI:

pip install statannot
You may instead want to use the development version from Github:

pip install git+https://github.com/webermarcolivier/statannot.git


## 二、说明：

import statannot
ax,
data=df,
x=x,
y=y,
hue=hue,
box_pairs=[
(("Biscoe", "Male"), ("Torgersen", "Female")),
(("Dream", "Male"), ("Dream", "Female")),
],
test="t-test_ind",
text_format="star",
loc="outside",
)


## 三、示例

### 案例1

import seaborn as sns

x = "day"
y = "total_bill"
order = ['Sun', 'Thur', 'Fri', 'Sat']
ax = sns.boxplot(data=df, x=x, y=y, order=order)
test_results = add_stat_annotation(ax, data=df, x=x, y=y, order=order,
box_pairs=[("Thur", "Fri"), ("Thur", "Sat"), ("Fri", "Sun")],
test='Mann-Whitney', text_format='star',
loc='outside', verbose=2)
test_results


### 案例2

x = "color"
y = "price"
hue = "cut"
hue_order=['Ideal', 'Premium', 'Good', 'Very Good', 'Fair']
box_pairs=[
(("E", "Ideal"), ("E", "Very Good")),
(("E", "Ideal"), ("E", "Good")),
(("I", "Ideal"), ("I", "Good")),
(("J", "Ideal"), ("J", "Good")),
(("E", "Good"), ("I", "Ideal")),