如何用单独的置信区间分割小提琴图

sky*_*hai 2 python seaborn violin-plot

我怎么能做出这样的小提琴人物呢?我想包括置信区间 在此输入图像描述 我可以使用下面的代码用四边形绘制分割图,但不能绘制均值和置信度。数据可以在这里找到。https://drive.google.com/file/d/18GrncA2GmJd38tVGZZ5yylR6Cf61XsGp/view?usp=sharing

import matplotlib.pyplot as plt
import seaborn as sns

sns.violinplot(x="six.categories", y="non_poor", hue="year", data=df, split=True,
               inner="quart", palette={"2019": "b", "2020": "y"})
sns.despine(left=True)

plt.xticks(np.arange(6),["Nonpoor\nWhite", "Poor\nWhite", "Poor\nBlack", "Nonpoor\nBlack", "Poor\nHispanic", "Nonpoor\nHispanic"])
Run Code Online (Sandbox Code Playgroud)

Diz*_*ahi 5

您可以组合 aviolinplot和 apointplot以获得所需的结果:

tips = sns.load_dataset('tips')
ax = sns.violinplot(x="day", y="total_bill", hue="smoker",
                    data=tips, palette="muted", split=True, inner=None)
sns.pointplot(x="day", y="total_bill", hue="smoker",
                    data=tips, dodge=0.2, join=False, palette=['white'], ax=ax)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述