BoxAnova is a Python package built on top of Seaborn Boxplots. Its main purpose is to create Boxplots with additional significance information. By using ANOVAs to evaluate if group and hue differences are significant, it adds significance information to the plot.
You can install BoxAnova using pip:
pip install BoxAnova
or Poetry
poetry add BoxAnova
Here is a simple example of how to use BoxAnova:
from BoxAnova import BoxAnova
import pandas as pd
# Load your data
df = pd.read_csv('your_data.csv')
# Initialize BoxAnova with your DataFrame, the group column, and the value column
box_anova = BoxAnova(df, variable='Value2', group='group')
# Plot the box plot with mean differences
box_anova.generate_box_plot()
There are some arguments you can set to change how the plots are generated:
- You can change orientation
box_anova = BoxAnova(df, variable='Value2', group='group', orient="V")
box_anova.generate_box_plot()
- If you want using stars or exact values
box_anova = BoxAnova(df, variable='Value2', group='group', show_p_value=True)
box_anova.generate_box_plot()
- If N of the groups should be displayed
python box_anova.generate_box_plot(fine_tuning_kws={"show_n": True})
Finally, you can add a second group.
box_anova.generate_box_plot(display='hue', hue="hue")
The main idea is you might want to genreate multiple plots at once. MultipleBOxAnova supports all functions of BoxAnova in addition it allows for multiple Variables.
For multiple box anova, you can use the multiple_box_anova
function:
from BoxAnova import multiple_box_anova
import pandas as pd
# Load your data
df = pd.read_csv('your_data.csv')
# Call the multiple_box_anova function
multiple_box_anova(variables=["first_variable", "second_variable"], data=df, group="group")
In both versions you can add the hue argument.
from BoxAnova import multiple_box_anova, BoxAnova
import pandas as pd
# Load your data
df = pd.read_csv('your_data.csv')
# BoxAnova
# Initialize BoxAnova with your DataFrame, the group column, and the value column
box_anova = BoxAnova(df, variable='first_variable', group='group_column' )
# Plot the box plot with hue
box_anova.plot_box_plot(hue="hue")
# Call the multiple_box_anova function
multiple_box_anova(variables=["first_variable", "second_variable"], data=df, group="group_column", hue="hue")
The multiple_box_anova does not require the initialization of the BoxAnova class
- Striplot in Boxplot BoxAnova(stripplot=True)
- Violinplot alternativ zu Boxplot BoxAnova(violin=True)
Contributions are welcome!