Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ratioplot1.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_hist
3## \notebook
4## Example creating a simple ratio plot of two histograms using the `pois` division option.
5## Two histograms are set up and filled with random numbers. The constructor of `TRatioPlot`
6## takes the to histograms, name and title for the object, drawing options for the histograms (`hist` and `E` in this case)
7## and a drawing option for the output graph.
8## Inspired by the tutorial of Paul Gessinger.
9##
10## \macro_image
11## \macro_code
12##
13## \author Alberto Ferro
14
15import ROOT
16
17ROOT.gStyle.SetOptStat(0)
18
19c1 = ROOT.TCanvas("c1", "A ratio example")
20h1 = ROOT.TH1D("h1", "h1", 50, 0, 10)
21h2 = ROOT.TH1D("h2", "h2", 50, 0, 10)
22f1 = ROOT.TF1("f1", "exp(- x/[0] )")
23f1.SetParameter(0,3)
24
25h1.FillRandom("f1",1900)
26h2.FillRandom("f1", 2000)
27h1.Sumw2()
28h2.Scale(1.9/2.)
29
30h1.GetXaxis().SetTitle("x")
31h1.GetYaxis().SetTitle("y")
32
33rp = ROOT.TRatioPlot(h1,h2)
34
35c1.SetTicks(0,1)
36rp.GetLowYaxis().SetNdivisions(505)
37c1.Update()
38c1.Draw()
39rp.Draw()
40