
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
fig = plt.figure(figsize=(12, 5))
ax1 = plt.subplot(121)
rs = np.random.RandomState(10) # 设定随机数种子
s = pd.Series(rs.randn(100) * 100)
sns.distplot(s, bins=10, hist=True, kde=True, rug=True, norm_hist=False, color='y', label='distplot', axlabel='x')
plt.legend()
ax1 = plt.subplot(122)
sns.distplot(s, rug=True,
hist_kws={"histtype": "step", "linewidth": 1, "alpha": 1, "color": "g"}, # 设置箱子的风格、线宽、透明度、颜色,风格包括:'bar', 'barstacked', 'step', 'stepfilled'
kde_kws={"color": "r", "linewidth": 1, "label": "KDE", 'linestyle': '--'}, # 设置密度曲线颜色,线宽,标注、线形
rug_kws={'color': 'r'}) # 设置数据频率分布颜色
plt.show()
函数及参数介绍:
distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None,hist_kws=None, kde_kws=None, rug_kws=None, fit_kws=None, color=None, vertical=False, norm_hist=False, axlabel=None, label=None, ax=None)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理