打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
转载: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()  

 

参考:http://blog.csdn.net/u013571243/article/details/48998619

 

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
如何驾驭Matplotlib?<Part1>
python数据可视化 | 绘制直方图实战-随机生成80万个数据展示数据分布区域变化
python+opencv图像处理(十三)
matplotlib基础绘图命令之hist
用 Python 生成直方图:你会怎么做?
OpenCV学习之直方图统计应用【转】
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服