I drew a plot showing the % of a categorical response (Categorical_DependentVar_xVSy) as a function of two binary categorical variables (called CategoricalVar1_aVSb and CategoricalVar3_cVSd) using teh seaborn package.
Would you know how to add the confidence interval to the percentgaes on the plot?
It is easy for means to have confidence intervals, but I do not find a way to add those for percentage/count plots.
Here is my code showing the % plot:
First I compute the percentages:
import seaborn as sns
DfInterpretation = (df.groupby(['CategoricalVar1_aVSb','CategoricalVar2_cVSd'])['Categorical_DependentVar_xVSy']
.value_counts(normalize=True)
.rename('percentage')
.mul(100)
.reset_index()
.sort_values('Categorical_DependentVar_xVSy'))
Then I plot the value from the table
g = sns.catplot(y = 'percentage', hue="CategoricalVar1_aVSb", x = "CategoricalVar2_cVSd",
col = "Categorical_DependentVar_xVSy",
data=DfInterpretation, kind="bar")
But I do not manage to get confidence intervals.
Any help would be greatly appreciated!
[[for information, it is possible with R - e.g.: https://stackoverflow.com/questions/58343088/how-to-add-95-confidence-intervals-to-graph-of-proportions-of-factor-levels-in but I could not find in python]]