簡體   English   中英

在Seaborn小提琴圖上繪制其他分位數

[英]Plot Additional Quantiles on Seaborn Violin Plots

使用http://seaborn.pydata.org/generation/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)

小提琴情節http://seaborn.pydata.org/_images/seaborn-violinplot-2.png

如何在每個小提琴的頂部繪制兩條小水平線(如誤差條的上限指示分布的2.5%和97.5%)?

這是一個很棘手的解決方案:

在小提琴圖的上方繪制另一個箱形圖怎么樣? (並在方框圖中隱藏方框。)

這是使用2.5和97.5的輸出:

在此處輸入圖片說明

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()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM