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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

直方图python高度_python – 子图中直方图的动画

發布時間:2023/12/4 python 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 直方图python高度_python – 子图中直方图的动画 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

normed =直方圖的True參數使直方圖繪制分布的密度.從the documentation開始:

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), i.e., the integral of the histogram will sum to 1. If stacked is also True, the sum of the histograms is normalized to 1.

Default is False

這意味著直方圖條的高度取決于箱寬度.如果僅繪制一個數據點,則動畫開始時的情況下,條形高度將為1./binwidth.如果箱寬度小于零,則桿高度可能變得非常大.

因此,在整個動畫過程中修復分檔并使用它們是個好主意.

清除軸也是合理的,這樣就不會繪制100個不同的直方圖.

import numpy as np

from matplotlib.pylab import *

import matplotlib.animation as animation

# generate 4 random variables from the random, gamma, exponential, and uniform distribution

x1 = np.random.normal(-2.5, 1, 10000)

x2 = np.random.gamma(2, 1.5, 10000)

x3 = np.random.exponential(2, 10000)+7

x4 = np.random.uniform(14,20, 10000)

fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2)

def updateData(curr):

if curr <=2: return

for ax in (ax1, ax2, ax3, ax4):

ax.clear()

ax1.hist(x1[:curr], normed=True, bins=np.linspace(-6,1, num=21), alpha=0.5)

ax2.hist(x2[:curr], normed=True, bins=np.linspace(0,15,num=21), alpha=0.5)

ax3.hist(x3[:curr], normed=True, bins=np.linspace(7,20,num=21), alpha=0.5)

ax4.hist(x4[:curr], normed=True, bins=np.linspace(14,20,num=21), alpha=0.5)

simulation = animation.FuncAnimation(fig, updateData, interval=50, repeat=False)

plt.show()

總結

以上是生活随笔為你收集整理的直方图python高度_python – 子图中直方图的动画的全部內容,希望文章能夠幫你解決所遇到的問題。

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