【问题标题】:Make sns.swarmplot with respect to two categorical variables in x-axis针对 x 轴上的两个分类变量制作 sns.swarmplot
【发布时间】:2020-06-21 01:42:16
【问题描述】:

我有一个 pandas DataFrame,我可以制作一个性别年龄群体图(图片有两列男性和女性)。还有糖尿病年龄群体图(两列是和否)

如何制作一个有四列的群体图:

男&是男&没有女&是女&没有

【问题讨论】:

    标签: python pandas seaborn swarmplot


    【解决方案1】:

    你可以使用sbn.swarmplot的hue参数:

    g = sbn.swarmplot(x="Gender", y="Age", hue="Diabetes", data=data, dodge=True, size=10)
    

    这给出了:

    【讨论】:

    • 谢谢。如果我们有三个类别呢? (所以我们想要八列)@Michael
    • 然后就可以开始使用sbn.catplot了。这允许您进一步使用行分层和列分层在类别之间进行拆分。
    猜你喜欢
    • 2019-10-21
    • 1970-01-01
    • 2023-03-31
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 2021-03-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多