gpt4 book ai didi

python - 在 Seaborn PairGrid 中使用 lmplot

转载 作者:行者123 更新时间:2023-12-05 02:07:36 26 4
gpt4 key购买 nike

我试图绘制一个 PairGrid 在对角线上使用密度估计,在上三角部分和下三角中的成对线性回归模型部分。这是我的数据文件:

df.head()

enter image description here这是我的代码:

g = sns.PairGrid(df, hue="quality bin")
g = g.map_upper(sns.scatterplot)
g = g.map_lower(sns.lmplot)
g = g.map_diag(sns.kdeplot)
g = g.add_legend()

但是我得到这个错误:TypeError: lmplot() got an unexpected keyword argument 'label'

最佳答案

您很可能需要 sns.regplot(),我认为 sns.lmplot() 中的方面正在搞砸。看看下面是否适合你:

import pandas as pd
import seaborn as sns
df = pd.read_csv("wine_dataset.csv")
df.columns
df = df[['fixed_acidity', 'volatile_acidity', 'citric_acid', 'residual_sugar','quality']]
df['quality'] = ['high' if i > 5 else 'low' for i in df['quality']]
g = sns.PairGrid(df, hue="quality")
g = g.map_upper(sns.scatterplot)
g = g.map_lower(sns.regplot,scatter_kws = {'alpha': 0.1,'s':3})
g = g.map_diag(sns.kdeplot)
g = g.add_legend()

enter image description here

关于python - 在 Seaborn PairGrid 中使用 lmplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61599587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com