Python 在Seaborn PairGrid中使用lmplot

Python 在Seaborn PairGrid中使用lmplot,python,matplotlib,seaborn,scatter-plot,lmplot,Python,Matplotlib,Seaborn,Scatter Plot,Lmplot,我正在尝试使用对角线上的密度估计绘制一个PairGrid,图中的散点图 上三角部分和下三角部分的两两线性回归模型 部分这是我的dataftame: df.head() 这是我的代码: 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() 但是我得到了这

我正在尝试使用对角线上的密度估计绘制一个
PairGrid
,图中的散点图 上三角部分和下三角部分的两两线性回归模型 部分这是我的dataftame:

df.head()
这是我的代码:

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()得到了一个意外的关键字参数'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()