美文网首页生物信息学与算法大数据
Seaborn入门(三): 实现Violinplots

Seaborn入门(三): 实现Violinplots

作者: 生信编程日常 | 来源:发表于2020-02-11 17:59 被阅读0次

小提琴图(violinplot)结合了箱线图和核密度图,可以反映任意位置的密度。

seaborn.violinplot基本参数为:
violinplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, bw='scott', cut=2, scale='area', scale_hue=True, gridsize=100, width=0.8, inner='box', split=False, dodge=True, orient=None, linewidth=None, color=None, palette=None, saturation=0.75, ax=None, **kwargs)

下边试举几例:

import seaborn as sns
sns.set(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(x=tips["total_bill"])
simple
ax = sns.violinplot(x="day", y="total_bill", data=tips)
vertical

分组:

ax = sns.violinplot(x="day", y="total_bill", hue="smoker",
                    data=tips, palette="muted")
group

将两组合到一起:

ax = sns.violinplot(x="day", y="total_bill", hue="smoker",
                    data=tips, palette="muted", split=True)
image.png

加上四分位数:

ax = sns.violinplot(x="day", y="total_bill", hue="sex",
                    data=tips, palette="Set2", split=True,
                    scale="count", inner="quartile")
quartiles

catplot分面:

g = sns.catplot(x="sex", y="total_bill",
                hue="smoker", col="time",
                data=tips, kind="violin", split=True,
                height=4, aspect=.7)
catplot

欢迎关注公众号~


生信编程日常

相关文章

网友评论

    本文标题:Seaborn入门(三): 实现Violinplots

    本文链接:https://www.haomeiwen.com/subject/mzuxfhtx.html