2017-07-07 27 views
0

我無法得到迴歸線和方差周圍界定,而截至http://seaborn.pydata.org/generated/seaborn.pairplot.html無法得到迴歸線和Seaborn方差界限pairplot

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

回答

1

迴歸線所示的例子繪製seaborn.pairplotkind=reg在那裏,你只是沒有看到它,因爲它隱藏在劇情中不自然的高點上。

enter image description here

因此,讓我們減少點的數量,你會看到迴歸預期。

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

enter image description here

+0

感謝@ImportanceOfBeingErnes。這只是示例數據。不知何故,真正的數據(這是數以十萬計,但不填滿整個面板),我仍然無法看到這些線。 – Rahul

+1

那麼,從問題中看不到代碼行的原因顯然是點的數量。當然,我們只能通過使用您向我們展示的代碼來幫助您。如果您的情況不同,請嘗試找到問題的[mcve],這實際上可以幫助您解決實際問題。否則,我們無法幫助。 – ImportanceOfBeingErnest