直方图
seaborn的displot()集合了matplotlib的hist()与核函数估计kdeplot的功能,增加了rugplot分布观测条显示与利用scipy库fit拟合参数分布的新颖用途。
具体用法如下:
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, 1d-array, or list.数据
Observed data. If this is a Series object with a name attribute, the name will be used to label the data axis.
bins : argument for matplotlib hist(), or None, optional #设置矩形图数量
Specification of hist bins, or None to use Freedman-Diaconis rule.
hist : bool, optional #控制是否显示条形图
kde : bool, optional #控制是否显示核密度估计图
rug : bool, optional #控制是否显示观测的小细条(边际毛毯)
fit : random variable object, optional #控制拟合的参数分布图形
{hist, kde, rug, fit}_kws : dictionaries, optional
Keyword arguments for underlying plotting functions.
vertical : bool, optional #显示正交控制If True, oberved values are on y-axis.
实例
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="white", palette="muted", color_codes=True)#设置主题、尺寸大小以及调色板。
rs = np.random.RandomState(10)
# Set up the matplotlib figure
f, axes = plt.subplots(2, 2, figsize=(7, 7), sharex=True)
sns.despine(left=True)#