当前位置: 代码迷 >> 综合 >> seaborn distplot 用法
  详细解决方案

seaborn distplot 用法

热度:41   发布时间:2023-12-19 04:13:01.0

1. 介绍

seaborn.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)

其中,
a : 序列Series或列表或1维数组;
bins : 直方图桶的个数;
hist : bool, optional,是否绘制直方图;
color : matplotlib color, optional;
label : string, optional,说明的标签;
ax : matplotlib axis, optional;
kde : bool, optional,Whether to plot a gaussian kernel density estimate.
rug : bool, optional,Whether to draw a rugplot on the support axis.
fit : random variable object, optional;An object with fit method, returning a tuple that can be passed to a pdf method a positional arguments following an grid of values to evaluate the pdf on.

vertical : bool, optional;If True, observed values are on y-axis.
norm_hist : bool, optional
If True, the histogram height shows a density rather than a count. This is implied if a KDE or fitted density is plotted.
axlabel : string, False, or None, optional
Name for the support axis label. If None, will try to get it from a.namel if False, do not set a label.

2. 使用

示例1:

import seaborn as sns,numpy as np
sns.set()
np.random.seed(0)
x=np.random.randn(100)
ax=sns.distplot(x)

效果:

在这里插入图片描述


示例2:

ax = sns.distplot(x, fit=norm, kde=False)

在这里插入图片描述


reference:

  1. seaborn tutorials
  相关解决方案