Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在seaborn线性回归jointplot中显示回归线_Python_Regression_Seaborn - Fatal编程技术网

Python 如何在seaborn线性回归jointplot中显示回归线

Python 如何在seaborn线性回归jointplot中显示回归线,python,regression,seaborn,Python,Regression,Seaborn,如中所述,以下代码将生成线性回归图 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="bi

如中所述,以下代码将生成线性回归图

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()

但它也没有显示出界线。但将其与
jointplot
结合使用:

sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="reg")
sns.regplot(x="bill_length_mm", y="bill_depth_mm", data=penguins)

这很奇怪。我尝试了你共享的代码,我可以在绘图中看到一行。我正在用一个笔记本电脑。我建议你检查一下是否有这两个软件包的最新版本。谢谢你的回复。更新这些软件包帮不了我。很抱歉,我只有这些。我一直在寻找同样的东西。口头解释通常是有帮助的
sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="reg")
sns.regplot(x="bill_length_mm", y="bill_depth_mm", data=penguins)
 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, x="bill_length_mm", 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)