2
如何使用散景生成加權數據的直方圖?使用散景的加權數據的直方圖
在matplotlib,可以做到以下幾點:
from pylab import hist
x = randn(100); w = rand(100)
hist(x, weights=w)
如何做同樣的事情在背景虛化?
如何使用散景生成加權數據的直方圖?使用散景的加權數據的直方圖
在matplotlib,可以做到以下幾點:
from pylab import hist
x = randn(100); w = rand(100)
hist(x, weights=w)
如何做同樣的事情在背景虛化?
基本上,你將權重傳遞給你的numpy的直方圖函數。
import numpy as np
from bokeh.layouts import gridplot
from bokeh.plotting import figure, show, output_file
p1 = figure(title="Normal Distribution (μ=50, σ=20) and normal weights",tools="save",
background_fill_color="#E8DDCB")
measured = np.random.normal(50, 20, 1000)
myweights = np.random.normal(0, 1, 1000)
hist, edges = np.histogram(measured, density=True, bins=10,weights=myweights)
x = np.linspace(-2, 2, 1000)
p1.quad(top=hist, bottom=0, left=edges[:-1], right=edges[1:],
fill_color="#036564", line_color="#033649")
p1.legend.location = "top_left"
p1.xaxis.axis_label = 'x'
p1.yaxis.axis_label = 'Pr(x)'
show(p1)
基本上,你複製了Bokeh的例子沒有進一步的解釋。 –