关于hist
"""
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). 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分的分布情况
""" 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 = 7
# the histogram of the data
n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='blue', alpha=0.9)
# 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() plt.plot(n)
plt.title('n values')
plt.show() plt.plot(bins)
plt.title('bins values')
plt.show()
关于hist的更多相关文章
- 频率直方图(hist)
频率直方图(frequency histogram)亦称频率分布直方图.统计学中表示频率分布的图形.在直角坐标系中,用横轴表示随机变量的取值,横轴上的每个小区间对应一个组的组距,作为小矩形的底边:纵轴 ...
- MATLAB实现频数直方图——hist的使用
"hist" is short for "Histogram(直方图.柱状图)". 1.N = hist(Y) bins the elements of Y ...
- hist和bar画图关系
1.hist是绘制直方图,直方图显示了数据值的分布情况. 1>n = hist(Y,n) 将向量Y中的元素分到n个等间隔的范围内(默认为10个间隔),并返回每个范围内元素的个数作为一 ...
- matplotlib.pyplot.hist
**n, bins, patches = plt.hist(datasets, bins, normed=False, facecolor=None, alpha=None)** ## 函数说明 用于 ...
- MATLAB绘图hist
刚登上号,已经学了一半了,就从现在开始写吧 以前学过的东西老忘,所以就注册个账号就当做记笔记吧 MATLAB在原来的数组中增加新行 A=[A;B]%B是要增加的行: hist使用方法 y=4*rand ...
- 4.6Python数据处理篇之Matplotlib系列(六)---plt.hist()与plt.hist2d()直方图
目录 目录 前言 (一)直方图 (二)双直方图 目录 前言 今天我们学习的是直方图,导入的函数是: plt.hist(x=x, bins=10) 与plt.hist2D(x=x, y=y) (一)直方 ...
- 【R作图】lattice包,画多个分布柱形图,hist图纵轴转换为百分比
一开始用lattice包,感觉在多元数据的可视化方面,确实做得非常好.各种函数,可以实现任何想要实现的展示. barchart(y ~ x) y对x的直方图 bwplot(y ~ x) 盒形图 den ...
- [Bayes] Point --> Hist: Estimate "π" by R
Verify the Monte Carlo sampling variability of "π". p = π/4 与 所得 0.7854 比较接近,故满足 Central L ...
- [Bayes] Hist & line: Reject Sampling and Importance Sampling
吻合度蛮高,但不光滑. > L= > K=/ > x=runif(L) > *x*(-x)^/K)) > hist(x[ind],probability=T, + xla ...
- 机器学习入门-数值特征-连续数据离散化(进行分段标记处理) 1.hist(Dataframe格式直接画直方图)
函数说明: 1. .hist 对于Dataframe格式的数据,我们可以使用.hist直接画出直方图 对于一些像年龄和工资一样的连续数据,我们可以对其进行分段标记处理,使得这些连续的数据变成离散化 就 ...
随机推荐
- Android中关于系统Dialog无法全屏的问题(dialog样式)
自定义一个Dialog,继承了系统Dialog的样式.这时候会发现,即使布局文件中写的width和height都是match_parent,依然无法达到全屏的效果. 原因是:系统dialog的样式.默 ...
- python3 str和bytes转换
bytes object b = b"example" str object s = "example" #str to bytes bytes(s, enco ...
- 探测web服务器质量——pycurl
pycurl是一个用C语言写的libcurl Python实现,功能非常强大,支持的操作协议有FTP.HTTP.HTTPS.TELNET等,可以理解为Linux下curl命令功能的Python封装,简 ...
- Python 自定义模块的打包和发布
写了一个Python模块,要求打包发布,供同事们使用,好吧,查了一下,网上大部分教程没有一个能把话说明白,不过最后还是解决了,特此记录一下, 以免下次遇到同样问题,也帮助其他有缘人,哈哈. 首先看一下 ...
- MySQL 创建索引(Create Index)的方法和语法结构及例子
MySQL 创建索引(Create Index)的方法和语法结构及例子 MySQL 创建索引(Create Index)的方法和语法结构及例子 CREATE INDEX Syntax CREATE ...
- ubuntu14.04 在自带python2.7上安装python3.3.5 可以用但是有问题
一开始写的时候并没有发现这么安装有问题,后来发现问题也不想删了,当个教训,如果想安装从python自带版本换别的版本的话就别接着看了,这么安装有问题.需要进行配置,但是我还不会.其实下面只是差了一步配 ...
- Python核心编程课后习题-第六章
1. 字符串, string模块中是否有一种字符串方法或者函数可以帮我鉴定一下一个字符串是否是另一个大字符串的一部分? str1 = 'abcdefghijklmnopqrstuv' print st ...
- UVA 101 vector
题目链接 白书上的例题,关于vector的使用.不定长数组vector,类型内部封装了一些常用操作.vector就像一个二维数组,只有第一维的大小是固定的,可以像数组一样访问到其中的每一个元素. ve ...
- Delphi中 为DBNavigator的按钮加中文
Delphi中 为DBNavigator的按钮加中文 /*Delphi中数据库控件DBNavigator使用起来不错,但是按钮上“+”.“-”等含义对于中国的用户不习惯,甚至不知道是什么含义.改成相应 ...
- EntityFramework 学习 一 Update Existing Entity using DBContext in Disconnected Scenario
using System; using System.Collections.Generic; public partial class Student { public Student() { th ...