[英]How to plot a jointplot with 'hue' parameter in seaborn
我想要以下命令行的情节:
import numpy as np, pandas as pd
import seaborn as sns; sns.set(style="white", color_codes=True)
tips = sns.load_dataset("tips")
g = sns.jointplot(x="total_bill", y="tip", data=tips, hue= 'sex')
如果在jointplot中实现了参数'hue'。
我该怎么做?
也许叠加两个联合情节?
此功能是在 2020 年 9 月的v0.11 Seaborn 版本中添加的(参见例如发布博客文章或文档)。
该文档现在提供了一个基于企鹅数据集的出色示例:
penguins = sns.load_dataset("penguins")
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")
我还想在联合图中给出一个核密度估计的最小例子(一个 2d kdeplot ):
# optional: sns.set(style='darkgrid')
data = {'x': [1, 2, 3, 4, 5, 6],
'y': [2, 4, 1.5, 4, 3, 5],
'class': ['1', '1', '1', '0', '0', '0']}
sns.jointplot(data=data, x='x', y='y', hue='class', kind='kde',
fill=True, joint_kws={'alpha': 0.7})
你不能,不幸的是
并且近期不会实现,因为应该保留jointplot的简单性。
见这里: https : //github.com/mwaskom/seaborn/issues/365
你只能做到一半(两个类都没有历史): 在 seaborn.jointplot 中绘制两个分布
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.