简体   繁体   English

无法获取Seaborn对图中的回归线和方差边界

[英]Unable to get Regression line and the variance bounds in Seaborn pairplot

I am unable to get regression line and the variance bounds around it while plotting seaborn.pairplot with kind=reg as shown in the examples at http://seaborn.pydata.org/generated/seaborn.pairplot.html 当使用kind=reg绘制seaborn.pairplot ,如http://seaborn.pydata.org/generated/seaborn.pairplot.html上的示例所示,我无法获得回归线及其周围的方差范围。

import pandas pd
import seaborn as sns
import numpy as np
import matplotlib as plt
# Preparing random dataFrame with two colums, viz., random x and lag-1 values 
lst1 = list(np.random.rand(10000))
df = pd.DataFrame({'x1':lst1})
df['x2'] = df['x1'].shift(1)
df = df[df['x2'] > 0]
# Plotting now
pplot = sns.pairplot(df, kind="reg")
pplot.set(ylim=(min(df['x1']), max(df['x1'])))
pplot.set(xlim=(min(df['x1']), max(df['x1'])))
plt.show()

The regression line is there, you just don't see it, because it's hidden by the unnaturally high number of points in the plot. 回归线就在那儿,您只是看不到它,因为它被图中不自然地高数量的点所隐藏。

在此处输入图片说明

So let's reduce the number of points and you'll see the regression as expected. 因此,让我们减少点的数量,您将看到预期的回归。

import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
# Preparing random dataFrame with two colums, viz., random x and lag-1 values 
lst1 = list(np.random.rand(100))
df = pd.DataFrame({'x1':lst1})
df['x2'] = df['x1'].shift(1)
df = df[df['x2'] > 0]
# Plotting now
pplot = sns.pairplot(df, kind="reg")

plt.show()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM