问题描述
如seaborn API中所述,以下代码将生成线性回归图。
import seaborn as sns
import matplotlib.pyplot as plt
# loading dataset
penguins = sns.load_dataset("penguins")
# draw jointplot with reg kind
sns.jointplot(data=penguins,x="bill_length_mm",y="bill_depth_mm",kind="reg")
解决方法
我也尝试使用regplot()
sns.regplot(x="bill_length_mm",y="bill_depth_mm",data=penguins)
但是它也没有显示行。但是,将其与jointplot
结合使用:
sns.jointplot(data=penguins,x="bill_length_mm",kind="reg")
sns.regplot(x="bill_length_mm",data=penguins)
Post Authentication Lambda Trigger
, try JointGrid it combines two plots into one. In this cat a regplot and a distplot. The regplot shows the linear regression trend and the distplot shows the data distribution in one graph
import scipy.stats as stats
g=sns.JointGrid(data=df,y="bill_depth_mm")
g.plot(sns.regplot,sns.distplot)
or
g=g.plot_joint(sns.kdeplot)
g=g.plot_marginals(sns.kdeplot,shade=True)
g=g.annotate(stats.pearsonr)