在Seaborn小提琴情节上绘制额外的分位数

时间:2017-01-08 05:56:12

标签: python seaborn violin-plot

使用http://seaborn.pydata.org/generated/seaborn.violinplot.html上的示例:

import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(x="day", y="total_bill", data=tips)

Violin plot http://seaborn.pydata.org/_images/seaborn-violinplot-2.png

如何在每个小提琴的顶部绘制两条小水平线(如误差条的大小,表示分布的2.5百分位和97.5百分位?

1 个答案:

答案 0 :(得分:3)

这是一个相当苛刻的解决方案:

如何在你的Violin剧情上绘制另一个箱线图? (并将方框隐藏在方框图中。)

以下是使用2.5和97.5的输出:

enter image description here

import seaborn as sns
import matplotlib.pyplot as plt

sns.set_style("whitegrid")
tips = sns.load_dataset("tips")

sns.boxplot(x="day", y="total_bill", data=tips, showfliers=False, showbox=False, whis=[2.5,97.5])
sns.violinplot(x="day", y="total_bill", data=tips)

plt.show()
相关问题