python怎么使用seaborn绘制直方图,密度图,散点图

发布时间:2022-07-14 10:30:38 作者:iii
来源:亿速云 阅读:503

本文小编为大家详细介绍“python怎么使用seaborn绘制直方图,密度图,散点图”,内容详细,步骤清晰,细节处理妥当,希望这篇“python怎么使用seaborn绘制直方图,密度图,散点图”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

一、直方图distplot()

python怎么使用seaborn绘制直方图,密度图,散点图

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)

二、密度图

2.1 单个样本数据分布密度图

python怎么使用seaborn绘制直方图,密度图,散点图

读到这里,这篇“python怎么使用seaborn绘制直方图,密度图,散点图”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. python如何绘制直方图和密度图
  2. python中Seaborn怎么画散点图

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python seaborn

上一篇:C#任务并行Parellel.For和Parallel.ForEach怎么使用

下一篇:C#面向对象编程中的里氏替换原则是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》