Logo ROOT   6.12/06
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Namespaces
ratioplot1.py File Reference

Namespaces

 ratioplot1
 

Detailed Description

Example creating a simple ratio plot of two histograms using the pois division option.

Two histograms are set up and filled with random numbers. The constructor of TRatioPlot takes the to histograms, name and title for the object, drawing options for the histograms (hist and E in this case) and a drawing option for the output graph. Inspired by the tutorial of Paul Gessinger.

pict1_ratioplot1.py.png
1 
2 import ROOT
3 
4 ROOT.gStyle.SetOptStat(0)
5 
6 c1 = ROOT.TCanvas("c1", "A ratio example")
7 h1 = ROOT.TH1D("h1", "h1", 50, 0, 10)
8 h2 = ROOT.TH1D("h2", "h2", 50, 0, 10)
9 f1 = ROOT.TF1("f1", "exp(- x/[0] )")
10 f1.SetParameter(0,3)
11 
12 h1.FillRandom("f1",1900)
13 h2.FillRandom("f1", 2000)
14 h1.Sumw2()
15 h2.Scale(1.9/2.)
16 
17 h1.GetXaxis().SetTitle("x")
18 h1.GetYaxis().SetTitle("y")
19 
20 rp = ROOT.TRatioPlot(h1,h2)
21 
22 c1.SetTicks(0,1)
23 rp.GetLowYaxis().SetNdivisions(505)
24 c1.Update()
25 c1.Draw()
26 rp.Draw()
27 
Author
Alberto Ferro

Definition in file ratioplot1.py.