[英]How to use `seaborn` to distplot an array of double value in Python3.6?
I tried to use distplot
to plot an array of double value but failed. 我试图使用
distplot
绘制一个双distplot
值数组,但失败了。 Below is my source code: 下面是我的源代码:
>>> import seaborn as sns, numpy as np
>>> sns.set(); np.random.seed(0)
>>> x = np.random.randn(100)
>>> ax = sns.distplot(x)
Below is the error I got. 以下是我得到的错误。 I don't know what wrong with my code.
我不知道我的代码有什么问题。 Does anyone know the issue?
有人知道这个问题吗?
>>> 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
BTW, I am using python3.6. 顺便说一句,我正在使用python3.6。
This is caused by an old version of statsmodels
and the problem is fixed in version 0.8.0. 这是由
statsmodels
的旧版本引起的,并且该问题已在版本0.8.0中修复。 Upgrade it as described in https://github.com/mwaskom/seaborn/issues/1092 如https://github.com/mwaskom/seaborn/issues/1092中所述升级它
conda update statsmodels
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.