python基础编程:关于python中plt.hist参数的使用详解

更新时间:2023-07-20 17:48:26 阅读: 评论:0

岁晏有余粮
python基础编程:关于python中plt.hist参数的使⽤详解
今天⼩编就为⼤家分享⼀篇关于python中plt.hist参数的使⽤详解,具有很好的参考价值,希望对⼤家有所帮助。⼀起跟随⼩编过来看看吧如下所⽰:
matplotlib.pyplot.hist(
x, bins=10, range=None, normed=Fal,
weights=None, cumulative=Fal, bottom=None,
histtype=u'bar', align=u'mid', orientation=u'vertical',
rwidth=None, log=Fal, color=None, label=None, stacked=Fal,
hold=None, **kwargs)
x : (n,) array or quence of (n,) arrays
这个参数是指定每个bin(箱⼦)分布的数据,对应x轴
bins : integer or array_like, optional
这个参数指定bin(箱⼦)的个数,也就是总共有⼏条条状图
normed : boolean, optional
If True, the first element of the return tuple will be the counts normalized to form a probability density, i.e.,n/(len(x)`dbin)
会计英语怎么说这个参数指定密度,也就是每个条状图的占⽐例⽐,默认为1
color : color or array_like of colors or None, optional
这个指定条状图的颜⾊
我们绘制⼀个10000个数据的分布条状图,共50份,以统计10000分的分布情况
"""
Demo of the histogram (hist) function with a few features.
In addition to the basic histogram, this demo shows a few optional features:
* Setting the number of data bins
邮件撤回* The ``normed`` flag, which normalizes bin heights so that the integral of
the histogram is 1. The resulting histogram is a probability density.
* Setting the face color of the bars
法宣平台
* Setting the opacity (alpha value).
茶叶简笔画"""
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
# example data
mu = 100 # mean of distribution
sigma = 15 # standard deviation of distribution
x = mu + sigma * np.random.randn(10000)
num_bins = 50
# the histogram of the data
孙俪短发图片n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='blue', alpha=0.5)
# add a 'best fit' line
家庭笑话
y = pdf(bins, mu, sigma)
plt.plot(bins, y, 'r--')
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')
清除内存
# Tweak spacing to prevent clipping of ylabel
plt.subplots_adjust(left=0.15)
plt.show()
、以上这篇关于python中plt.hist参数的使⽤详解就是⼩编分享给⼤家的全部内容了
最后给⼤家推荐⼀个⼝碑不错的公众号【程序员学府】,这⾥有很多的⽼前辈学习技巧,学习⼼得,⾯试技巧,职场经历等分享,更为⼤家精⼼准备了零基础⼊门资料,实战项⽬资料,每天都有程序员定时讲解Python技术,分享⼀些学习的⽅法和需要留意的⼩细节

本文发布于:2023-07-20 17:48:26,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1107296.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:分布   参数   基础
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图