Python基础——seaborn用法及实例

本文介绍了Python数据可视化库seaborn的使用,特别是直方图的绘制,包括displot()函数的详细参数和实例。同时,讲解了relplot()如何用于创建散点图以关联变量,并强调了线图在展示连续性数据中的作用。
摘要由CSDN通过智能技术生成

直方图

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)#

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值