"""
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的更多相关文章

  1. 频率直方图(hist)

    频率直方图(frequency histogram)亦称频率分布直方图.统计学中表示频率分布的图形.在直角坐标系中,用横轴表示随机变量的取值,横轴上的每个小区间对应一个组的组距,作为小矩形的底边:纵轴 ...

  2. MATLAB实现频数直方图——hist的使用

      "hist" is short for "Histogram(直方图.柱状图)". 1.N = hist(Y) bins the elements of Y ...

  3. hist和bar画图关系

    1.hist是绘制直方图,直方图显示了数据值的分布情况.  1>n = hist(Y,n)      将向量Y中的元素分到n个等间隔的范围内(默认为10个间隔),并返回每个范围内元素的个数作为一 ...

  4. matplotlib.pyplot.hist

    **n, bins, patches = plt.hist(datasets, bins, normed=False, facecolor=None, alpha=None)** ## 函数说明 用于 ...

  5. MATLAB绘图hist

    刚登上号,已经学了一半了,就从现在开始写吧 以前学过的东西老忘,所以就注册个账号就当做记笔记吧 MATLAB在原来的数组中增加新行 A=[A;B]%B是要增加的行: hist使用方法 y=4*rand ...

  6. 4.6Python数据处理篇之Matplotlib系列(六)---plt.hist()与plt.hist2d()直方图

    目录 目录 前言 (一)直方图 (二)双直方图 目录 前言 今天我们学习的是直方图,导入的函数是: plt.hist(x=x, bins=10) 与plt.hist2D(x=x, y=y) (一)直方 ...

  7. 【R作图】lattice包,画多个分布柱形图,hist图纵轴转换为百分比

    一开始用lattice包,感觉在多元数据的可视化方面,确实做得非常好.各种函数,可以实现任何想要实现的展示. barchart(y ~ x) y对x的直方图 bwplot(y ~ x) 盒形图 den ...

  8. [Bayes] Point --> Hist: Estimate "π" by R

    Verify the Monte Carlo sampling variability of "π". p = π/4 与 所得 0.7854 比较接近,故满足 Central L ...

  9. [Bayes] Hist & line: Reject Sampling and Importance Sampling

    吻合度蛮高,但不光滑. > L= > K=/ > x=runif(L) > *x*(-x)^/K)) > hist(x[ind],probability=T, + xla ...

  10. 机器学习入门-数值特征-连续数据离散化(进行分段标记处理) 1.hist(Dataframe格式直接画直方图)

    函数说明: 1. .hist 对于Dataframe格式的数据,我们可以使用.hist直接画出直方图 对于一些像年龄和工资一样的连续数据,我们可以对其进行分段标记处理,使得这些连续的数据变成离散化 就 ...

随机推荐

  1. 很详细、很移动的Linux makefile 教程

    近期在学习Linux下的C编程,买了一本叫<Linux环境下的C编程指南>读到makefile就越看越迷糊,可能是我的理解能不行. 于是google到了以下这篇文章.通俗易懂.然后把它贴出 ...

  2. mysql主从复制(linux下)

    转至:http://369369.blog.51cto.com/319630/790921 怎么安装mysql数据库,这里不说了,只说它的主从复制,步骤如下: 1.主从服务器分别作以下操作:   1. ...

  3. 每天一个Linux命令(34)grep命令

          grep(global search regular expression(RE) and print out the line,全面搜索正则表达式并把行打印出来)是一种强大的文本搜索工具 ...

  4. [原创]Scala学习:函数的定义

    方式一:标准的定义函数 def 函数名(参数1: 参数类型,参数2: 参数类型): 返回值类型 = { 函数体 } 例子 def max(x: Int,y: Int): Int ={ if(x > ...

  5. stack-铁轨问题

    每辆火车都从A方向驶入车站,再从B方向驶出车站,同时它的车厢可以进行某种形式的重新组合.假设从A方向驶来的火车有n节车厢(n<1000),分别按顺序编号为1,2,...,n.假定在进入车站之前每 ...

  6. OC实现将N个数随机排列

    + (NSMutableArray *)randArray : (NSMutableArray *)arrayM { NSMutableArray *resultM = [[NSMutableArra ...

  7. Spring Cloud之Hystrix雪崩效应解决方案

    基于Hystris解决雪崩效应: 1.服务降级:    防止用户一直等待,使用降级方式,调用FallBack(返回友好提示,不会去处理请求) 案例: 当前请求人数过多,请稍后重试 2.服务熔断:(和服 ...

  8. EntityFramework 学习 一 Entity Framework 查询设计

    First/FirstOrDefault: using (var ctx = new SchoolDBEntities()) { var student = (from s in ctx.Studen ...

  9. java自动生成表单简单实例

    数据库表设置 tb_form(form表单) 字段 类型 约束 说明 Id Int 主键 主键 Formid Varchar2(20) 唯一 Form表单id的值 Action Varchar2(20 ...

  10. Codeforces 900D Unusual Sequences:记忆化搜索

    题目链接:http://codeforces.com/problemset/problem/900/D 题意: 给定x,y,问你有多少个数列a满足gcd(a[i]) = x 且 ∑(a[i]) = y ...