关于python中plt.hist参数的使用详解
作者:我是卖报的小行家啦啦啦 发布时间:2021-07-05 05:57:23
标签:python,plt.hist
如下所示:
matplotlib.pyplot.hist(
x, bins=10, range=None, normed=False,
weights=None, cumulative=False, bottom=None,
histtype=u'bar', align=u'mid', orientation=u'vertical',
rwidth=None, log=False, color=None, label=None, stacked=False,
hold=None, **kwargs)
x : (n,) array or sequence 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 = mlab.normpdf(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()
来源:https://blog.csdn.net/qq_42600434/article/details/81626749
0
投稿
猜你喜欢
- 1.创建数据库连接,并打开set cnn=Server.CreateObject("ADODB.Connection&q
- 一、导入所需的库import randomimport cv2from matplotlib import pyplot as pltimp
- 使用图层可以像素为单位精确定位页面元素,并且可以将层放置在页面的任意位置。当把页面元素放入图层之中时,还可以控制哪个显示在前面、哪个显示在后
- 目前网络上有许多图片验证码形式,那些没有生成图片的验证码的抗破解防御能力简直不堪一击;有人直接在网页源码里显示出具体的数字,然后要求访问者输
- 1、epochKeras官方文档中给出的解释是:“简单说,epochs指的就是训练过程接中数据将被“轮”多少次”(1)释义:训练过程中当一个
- 目录你有过摸鱼时间吗实现思路运行环境界面布局定时刷新剩余时间完整代码你有过摸鱼时间吗在互联网圈子里,常常说996上班制,但是也不乏965的,
- 下半年毕业季,各种毕业设计纷涌而至,虽然学校教了Python,但是我相信各位肯定没有认真学,做作业就懵逼的那种~所以我都给大家准备好了!各种
- 本文较为详细的分析了php提示Failed to write session data错误的解决方法。分享给大家供大家参考。具体方法如下:一
- 公司网站后台使用的eWebEditor来添加发布新闻之类的,但把电脑的IE升级到8之后一直没办法添加附件之类的,症状就是在点击编辑器按钮时就
- 本文总结了input的各种使用方法,挺全面的1.取消按钮按下时的虚线框在input里添加属性值 hideFocus 或者 HideFocus
- 函数getcache,会自动建立需要的缓存。 代码如下:Function getcache(funsname,isreset,is
- 一、理解装饰器所有东西都是对象(函数可以当做对象传递)由于函数也是一个对象,而且函数对象可以被赋值给变量,所以,通过变量也能调用该函数。de
- 持续集成(CI)作业可以产生大量的数据。当作业失败时,找出了什么问题可能是一个繁琐的过程,需要对日志进行调查以发现根本原因-这通常是在作业总
- Yahoo发布了一款基于FireFox的插件,名叫YSlow,这个插件可以分析网站的页面,并告诉你为了提高网站性能,如何基于某些规则而进行优
- 函数内省(function introspection)除了__doc__属性, 函数对象还有很多属性,对于下面的函数,可以使用dir()查
- 功能说明: 滑动展开/收缩广告效果,可指定:广告完全展开时的停留时间,最大高度。兼容浏览器:IE5.0+、FF1.06+、Opera8.0+
- 粒子群算法粒子群算法源于复杂适应系统(Complex Adaptive System,CAS)。CAS理论于1994年正式提出,CAS中的成
- Summary主要包括以下三种途径:使用独立的函数;使用torch.type()函数;使用type_as(tesnor)将张量转换为给定类型
- 1、mysql的limit关键字 (DAO)select * from tablename limit startPoint, number
- 本文实例讲述了Python实现获取前100组勾股数的方法。分享给大家供大家参考,具体如下:本来想采用穷举试探的方式来做这个算法,后来发现还是