[英]using lmplot in Seaborn PairGrid
我正在嘗試使用對角線上的密度估計、上三角部分的散點圖和下三角部分的成對線性回歸模型來 plot 一個PairGrid
。 這是我的數據名稱:
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() 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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.