Seaborn没有显示累积分布

时间:2020-02-13 07:45:16

标签: python matplotlib seaborn

在较旧的项目中,我得到以下结果:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

f, axes = plt.subplots(1, 2, figsize=(15, 5), sharex=True)
sns.distplot(df['Ratio(%)'].dropna(), bins=50, ax=axes[0])
sns.kdeplot(df['Ratio(%)'].dropna(), cumulative=True, ax=axes[1])
plt.show()

enter image description here

该软件的版本如下:

  • Python 3.7.1 64位[MSC v.1915 64位(AMD64)]
  • IPython 7.2.0
  • OS Windows 10 10.0.17763 SP0
  • matplotlib 3.0.2
  • 熊猫0.23.4
  • 季节性0.9.0

现在,做同样的事情,我得到这个错误:

----> 1 sns.kdeplot(df['Ratio(%)'].dropna(), cumulative=True, ax=axes[1])   
ImportError: Cumulative distributions are currently only implemented in statsmodels. Please install statsmodels.

该软件的版本为:

  • Python 3.7.6 64位[MSC v.1916 64位(AMD64)]
  • IPython 7.11.1
  • OS Windows 10 10.0.18362 SP0
  • matplotlib 3.1.1
  • 熊猫0.25.3
  • 季节性0.10.0

但是,如果我更改代码:

sns.kdeplot(df['Ratio(%)'].dropna(), cumulative=False, ax=axes[1])

enter image description here

它可以工作,但不能达到我期望的图形。

0 个答案:

没有答案