0

I have this grouped boxplot with striplot:

import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

tips = sns.load_dataset("tips")

sns.stripplot(x="day", y="total_bill", hue="smoker",
data=tips, jitter=True,
palette=["red","blue"], dodge=True,linewidth=2,edgecolor='black', size=2.0)

# Get the ax object to use later.
ax = sns.boxplot(x="day", y="total_bill", hue="smoker",
data=tips,palette=["red","blue"],fliersize=0)

# Get the handles and labels. For this example it'll be 2 tuples
# of length 4 each.
handles, labels = ax.get_legend_handles_labels()

# When creating the legend, only use the first two elements
# to effectively remove the last two.
l = plt.legend(handles[0:2], labels[0:2], bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)

And it works fine, but I would like to add p-values above each group, and I am pretty new to this so I don't have the idea how to do it.

Thanks.

vldmrrdjcc
  • 2,082
  • 5
  • 22
  • 41
  • Before you expect an answer from readers, you should teach them how to get the p-values. Where are these p-values in your code? The problem is simple text annotation. Did you read the existing answers like [this](https://stackoverflow.com/questions/54891068/python-how-to-add-p-values-signifance-to-barplot) or [this](https://stackoverflow.com/questions/30228069/how-to-display-the-value-of-the-bar-on-each-bar-with-pyplot-barh) or [this](https://stackoverflow.com/questions/11517986/indicating-the-statistically-significant-difference-in-bar-graph) – Sheldore Jul 02 '19 at 08:41
  • Data comes from total_bill column, so the question is are those values correlated or not for smokers and non-smokers for each day and to put the mark (annotation) above each day groups. But I am not a Python programmer, so I will need more time to understand those answers that you put. Thanks anyway. – vldmrrdjcc Jul 02 '19 at 08:50

0 Answers0