webermarcolivier / statannot

add statistical annotations (pvalue significance) on an existing boxplot generated by seaborn boxplot
MIT License
395 stars 74 forks source link

Disclaimer

This repository is not maintained anymore. I recommend using the forked package trevismd/statannotations, which has a cleaner API and further extends the functionalities of statannot.

What is it

Python package to optionnally compute statistical test and add statistical annotations on an existing boxplot/barplot generated by seaborn.

Features

Installation

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

Documentation

See example jupyter notebook example/example.ipynb.

Usage

Here is a minimal example:

import seaborn as sns
from statannot import add_stat_annotation

df = sns.load_dataset("tips")
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

More examples are available in the jupyter notebook example/example.ipynb.

Examples

Example 1

Example 2

Requirements

Cite

A Digital Object Identifiers (DOIs) was created for the repository for easier referencing in the academic literature.