【问题标题】:split violinplot in seaborn with hue parameter使用色调参数在seaborn中分割小提琴图
【发布时间】:2016-02-18 03:55:12
【问题描述】:

我正在尝试仅使用seaborn 中的yhue 参数创建violinplotx 数据变量定义为无)。使用与我所做的文档中类似的示例:

tips = sns.load_dataset("tips")
sns.violinplot(y="total_bill", hue="sex", data=tips, split=True)

并且得到的图形不会根据色调变量进行分割。

当定义 x 变量时,绘图被分割。有没有办法在没有 x 输入的情况下在 seaborn 中进行拆分图?

【问题讨论】:

    标签: python matplotlib seaborn


    【解决方案1】:

    只需添加一个对所有条目都相同的变量并将其用作x

    tips = sns.load_dataset("tips")
    tips["all"] = ""
    ax = sns.violinplot(x="all", y="total_bill", hue="sex", data=tips, split=True)
    ax.set_xlabel("")
    

    【讨论】:

    猜你喜欢
    • 2022-01-23
    • 2016-06-13
    • 2018-05-19
    • 2023-03-31
    • 2020-07-03
    • 2015-10-16
    • 1970-01-01
    • 2018-01-19
    相关资源
    最近更新 更多