日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

关于hist

發布時間:2023/12/29 综合教程 22 生活家
生活随笔 收集整理的這篇文章主要介紹了 关于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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。