2017-09-30 66 views
0

我試圖用distplot來繪製double值的數組,但失敗了。以下是我的源代碼:如何在Python3.6中使用`seaborn`來描繪double值的數組?

>>> import seaborn as sns, numpy as np 
>>> sns.set(); np.random.seed(0) 
>>> x = np.random.randn(100) 
>>> ax = sns.distplot(x) 

下面是我得到的錯誤。我不知道我的代碼有什麼問題。有誰知道這個問題?

>>> ax = sns.distplot(x) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/anaconda/lib/python3.6/site-packages/seaborn/distributions.py", line 221, in distplot 
    kdeplot(a, vertical=vertical, ax=ax, color=kde_color, **kde_kws) 
    File "/anaconda/lib/python3.6/site-packages/seaborn/distributions.py", line 604, in kdeplot 
    cumulative=cumulative, **kwargs) 
    File "/anaconda/lib/python3.6/site-packages/seaborn/distributions.py", line 270, in _univariate_ 
kdeplot 
    cumulative=cumulative) 
    File "/anaconda/lib/python3.6/site-packages/seaborn/distributions.py", line 328, in _statsmodels 
_univariate_kde 
    kde.fit(kernel, bw, fft, gridsize=gridsize, cut=cut, clip=clip) 
    File "/anaconda/lib/python3.6/site-packages/statsmodels/nonparametric/kde.py", line 146, in fit 
    clip=clip, cut=cut) 
    File "/anaconda/lib/python3.6/site-packages/statsmodels/nonparametric/kde.py", line 506, in kden 
sityfft 
    f = revrt(zstar) 
    File "/anaconda/lib/python3.6/site-packages/statsmodels/nonparametric/kdetools.py", line 20, in 
revrt 
    y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j 
TypeError: slice indices must be integers or None or have an __index__ method 

順便說一句,我使用python3.6。

+0

上運行它的Python 2.7的作品精細描述;無法重現錯誤。 – Cleb

+0

我正在使用Python3.6。這是因爲版本不同嗎? –

回答

相關問題