博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于hist
阅读量:4677 次
发布时间:2019-06-09

本文共 1562 字,大约阅读时间需要 5 分钟。

"""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, optionalIf True, the first element of the return tuple will be the counts normalized to form a probability density, i.e.,n/(len(x)`dbin)这个参数指定密度,也就是每个条状图的占比例比,默认为1color : color or array_like of colors or None, optional这个指定条状图的颜色我们绘制一个10000个数据的分布条状图,共50份,以统计10000分的分布情况"""import numpy as npimport matplotlib.mlab as mlabimport matplotlib.pyplot as plt# example datamu = 100 # mean of distributionsigma = 15 # standard deviation of distributionx = mu + sigma * np.random.randn(10000)num_bins = 7# the histogram of the datan, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='blue', alpha=0.9)# add a 'best fit' liney = 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 ylabelplt.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()

转载于:https://www.cnblogs.com/qqhfeng/p/5336156.html

你可能感兴趣的文章
205 Isomorphic Strings
查看>>
318. Maximum Product of Word Lengths java solutions
查看>>
[bzoj1038] [ZJOI2008]瞭望塔
查看>>
远程桌面 习惯性注销连接,出事了
查看>>
软件工程基本概念
查看>>
MYSQL复习笔记5-select-from-where子句
查看>>
linux 如何释放缓存
查看>>
经典,程序员笑话
查看>>
Linux 抓取网站命令
查看>>
浪叫兽的自我介绍 (完整版) 讲述一段如何进入大数据行业
查看>>
Qt ui在程序中的使用
查看>>
datatables.js 简单使用--弹出编辑框或添加数据框
查看>>
前端--3、jQuery
查看>>
最小化的 Google Analytics 代码
查看>>
服务器监控相关
查看>>
转: 环信联合创始人:App主流反垃圾服务难点和技术实现全解析
查看>>
关于类型转换这件事
查看>>
[转]30分钟,让你成为一个更好的程序员
查看>>
《使用Hibernate开发租房系统》内部测试笔试题
查看>>
矩阵的奇异值与特征值
查看>>