使用 Seaborn Python 绘制 CDF + 累积直方图
Plot CDF + cumulative histogram using Seaborn Python
有没有办法仅使用 Seaborn 绘制 Python 中 Pandas 系列的 CDF + 累积直方图?我有以下内容:
import numpy as np
import pandas as pd
import seaborn as sns
s = pd.Series(np.random.normal(size=1000))
我知道我可以用 s.hist(cumulative=True, normed=1)
绘制累积直方图,我知道我可以用 sns.kdeplot(s, cumulative=True)
绘制 CDF,但我想要一些可以在 Seaborn 中同时完成的东西,就像什么时候使用 sns.distplot(s)
绘制分布,它给出了 kde 拟合和直方图。有办法吗?
import numpy as np
import seaborn as sns
x = np.random.randn(200)
kwargs = {'cumulative': True}
sns.distplot(x, hist_kws=kwargs, kde_kws=kwargs)
您可以通过使用 cumulative=True
和 density=True
使用 matplotlib 获得几乎相同的图。
plt.hist(x,cumulative=True, density=True, bins=30)
有没有办法仅使用 Seaborn 绘制 Python 中 Pandas 系列的 CDF + 累积直方图?我有以下内容:
import numpy as np
import pandas as pd
import seaborn as sns
s = pd.Series(np.random.normal(size=1000))
我知道我可以用 s.hist(cumulative=True, normed=1)
绘制累积直方图,我知道我可以用 sns.kdeplot(s, cumulative=True)
绘制 CDF,但我想要一些可以在 Seaborn 中同时完成的东西,就像什么时候使用 sns.distplot(s)
绘制分布,它给出了 kde 拟合和直方图。有办法吗?
import numpy as np
import seaborn as sns
x = np.random.randn(200)
kwargs = {'cumulative': True}
sns.distplot(x, hist_kws=kwargs, kde_kws=kwargs)
您可以通过使用 cumulative=True
和 density=True
使用 matplotlib 获得几乎相同的图。
plt.hist(x,cumulative=True, density=True, bins=30)