Exemple #1
0
# create a normal distribution
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

# create a histogram with 100 bins from 40 to 160
h = Hist(100, 40, 160)

# fill the histogram with our distribution
map(h.Fill, x)

# normalize the histogram
h /= h.Integral()

# set visual attributes
h.SetFillStyle('solid')
h.SetFillColor('green')
h.SetLineColor('green')

# the histogram of the data
plt.figure(figsize=(16, 12), dpi=200)
axes = plt.axes()
axes.minorticks_on()
rplt.hist(h, label=r'$\epsilon$(Something complicated)', alpha=0.7)
plt.xlabel('Discovery', CMS.x_axis_title)
plt.ylabel('Probability of a discovery', CMS.y_axis_title)
#plt.title(r'combined, CMS Preliminary, $\mathcal{L}$ = 5.1 fb$^{-1}$ at $\sqrt{s}$ = 7 TeV',
#          fontsize=30,
#          verticalalignment='bottom')
#plt.title(r'e+jets, CMS Preliminary, $\mathcal{L}$ = 5.1 fb$^{-1}$ at $\sqrt{s}$ = 7 TeV',
#fontsize=30,
#          verticalalignment='bottom')
Exemple #2
0
# create histograms
h1 = Hist(100, 40, 160)
h2 = Hist(100, 40, 160)

# fill the histograms with our distributions
map(h1.Fill, x1)
map(h2.Fill, x2)

# normalize the histograms
h1 /= h1.Integral()
h2 /= h2.Integral()

# set visual attributes
h1.SetFillStyle("solid")
h1.SetFillColor("green")
h1.SetLineColor("green")

h2.SetFillStyle("solid")
h2.SetFillColor("red")
h2.SetLineColor("red")

# plot with ROOT
h1.GetXaxis().SetTitle('Smarts')
h1.GetYaxis().SetTitle('Probability')
h1.SetTitle("Histogram of IQ: #mu=100, #sigma=15")
h1.Draw("hist")
h2.Draw("same")

# plot with matplotlib
plt.figure()
# create histograms
h1 = Hist(100, 40, 160)
h2 = Hist(100, 40, 160)

# fill the histograms with our distributions
map(h1.Fill, x1)
map(h2.Fill, x2)

# normalize the histograms
h1 /= h1.Integral()
h2 /= h2.Integral()

# set visual attributes
h1.SetFillStyle('solid')
h1.SetFillColor('green')
h1.SetLineColor('green')

h2.SetFillStyle('solid')
h2.SetFillColor('red')
h2.SetLineColor('red')

stack = HistStack()
stack.Add(h1)
stack.Add(h2)

# plot with ROOT
h1.SetTitle('Histogram of IQ: #mu=100, #sigma=15')
stack.Draw()
h1.GetXaxis().SetTitle('Smarts')
h1.GetYaxis().SetTitle('Probability')