本文整理汇总了Python中histogram.Histogram.fill方法的典型用法代码示例。如果您正苦于以下问题:Python Histogram.fill方法的具体用法?Python Histogram.fill怎么用?Python Histogram.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类histogram.Histogram
的用法示例。
在下文中一共展示了Histogram.fill方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mean
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
def test_mean(self):
h = Histogram(10,[0,10])
h.fill([3,3,3])
assert_almost_equal(h.mean()[0],3.5)
h.fill([1,5])
assert_almost_equal(h.mean()[0],3.5)
示例2: test_plot_hist2d
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
def test_plot_hist2d():
npoints = 100000
h2 = Histogram((100,(0,10),'x'),(100,(0,10),'y'),'z','title')
h2.fill(rand.normal(5,2,npoints),
rand.uniform(0,10,npoints))
fig,ax = pyplot.subplots(1,2)
ax[0].plothist(h2)
ax[1].plothist(h2)
ax[1].plothist(h2.smooth(1), style='contour', overlay=True)
pyplot.savefig('test_images/test_plotting_fig_hist2d.png')
示例3: test_plot_hist1d
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
def test_plot_hist1d():
npoints = 100000
h1 = Histogram(100,(0,10),'x','y','title')
h1.fill(rand.normal(5,2,npoints))
fig,ax = pyplot.subplots(2,2)
ax[0,0].plothist(h1, style='polygon' , baseline='bottom')
ax[0,1].plothist(h1, style='errorbar', baseline='bottom')
ax[1,0].plothist(h1, style='polygon' )#, baseline='left')
ax[1,1].plothist(h1, style='errorbar')#, baseline='left')
pyplot.savefig('test_images/test_plotting_fig_hist1d.png')
示例4: setUp
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
def setUp(self):
rc.overwrite.overwrite = 'always'
np.random.seed(1)
h = Histogram(100,[0,10],'Δx', 'y', 'title')
h.fill(np.random.normal(5,2,10000))
h.uncert = np.sqrt(h.data)
if sys.version_info < (3,0):
def _to_unicode(s):
if not isinstance(s,unicode):
return unicode(s,'utf-8')
else:
return s
h.title = _to_unicode(h.title)
h.label = _to_unicode(h.label)
for ax in h.axes:
ax.label = _to_unicode(ax.label)
self.h = h
示例5: Histogram
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
# -*- coding: utf-8 -*-
import numpy as np
from histogram import Histogram
np.random.seed(1)
h = Histogram(100,[0,10],'Δx', 'y', 'title')
h.fill(np.random.normal(5,2,10000))
h.uncert = np.sqrt(h.data)
示例6: Histogram
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
'''
Simple 2D histogram example.
'''
import numpy as np
from matplotlib import pyplot, cm
from histogram import Histogram, plothist
np.random.seed(1)
# 2D histogram with 30x40 bins
h = Histogram(30,[0,10],40,[-5,5])
# filling the histogram with some random data
npoints = 100000
datax = np.random.normal(5,1,npoints)
datay = np.random.uniform(-5,5,npoints)
h.fill(datax,datay)
# filling with even more data
datax = np.random.uniform(0,10,npoints)
datay = np.random.normal(0,1,npoints)
h.fill(datax,datay)
# using the plothist() convenience method
fig,ax,pt = plothist(h, cmap=cm.Blues)
# display figure to screen
pyplot.show()
示例7: Histogram
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
from numpy import random as rand
from matplotlib import pyplot
from histogram import Histogram
rand.seed(1)
npoints = 10000
xdata = rand.normal(100,50,npoints)
ydata = rand.normal(50,10,npoints)
d0 = (10, [0,100],'$x$')
d1 = (10,[-0.5,100.5],'$y$')
h2 = Histogram(d0,d1,'$z$','Random Data')
h2.fill(xdata,ydata)
h2slices = list(h2.slices())
axslices = h2.axes[0]
fig = pyplot.figure(figsize=(12,12))
axs,saxs = fig.plothist_strip(h2slices,axslices)
pyplot.show()
示例8: Histogram
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
from numpy import random as rand
from matplotlib import pyplot, cm
from histogram import Histogram
npoints = 1000000
datax = rand.normal(100,40,npoints)
datay = rand.normal(100,60,npoints)
dataz = rand.normal(50,20,npoints)
d0 = (10,[0,100],'x')
d1 = (9, [0,100],'y')
d2 = (100,[0,100],'z')
h3 = Histogram(d0,d1,d2,'counts','Random Data')
h3.fill(datax,datay,dataz)
fig = pyplot.figure(figsize=(12,12))
axs,axtot,axins = fig.plothist_grid(h3, cmap=cm.copper_r)
pyplot.show()
示例9: test_occupancy
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
def test_occupancy(self):
h = Histogram(10,[0,10])
h.fill([1,1,1,2,2,2,3])
hocc = h.occupancy(4,[-0.5,3.5])
assert_array_almost_equal(hocc.data, [7,1,0,2])
示例10: use
# 需要导入模块: from histogram import Histogram [as 别名]
# 或者: from histogram.Histogram import fill [as 别名]
import numpy as np
from histogram import Histogram
import matplotlib.pyplot as plt
from matplotlib.style import use
use('ggplot')
hist1 = Histogram(100, [0, 10])
hist2 = Histogram(100, [0, 10])
for i in range(1000):
hist1.fill(np.random.normal(5, 1, 10000))
hist2.fill(np.random.exponential(2, 10000))
print(hist2.n_entries)
print(hist2.n_underflow)
print(hist2.n_overflow)
hist1.plot()
hist2.plot(kind='bar', alpha=0.3)
plt.xlim(-0.1, 10.1)
plt.show()