本文介绍了使用Seaborn Python绘制CDF +累积直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以仅使用Seaborn来绘制Python中熊猫系列的CDF +累积直方图?我有以下内容:
Is there a way to plot the CDF + cumulative histogram of a Pandas Series in Python using Seaborn only? I have the following:
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中可以做到这两者,就像用,这会同时给出kde拟合和直方图.有办法吗?
I know I can plot the cumulative histogram with s.hist(cumulative=True, normed=1)
, and I know I can then plot the CDF using sns.kdeplot(s, cumulative=True)
, but I want something that can do both in Seaborn, just like when plotting a distribution with sns.distplot(s)
, which gives both the kde fit and the histogram. Is there a way?
推荐答案
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)
这篇关于使用Seaborn Python绘制CDF +累积直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!