Logo ROOT   6.12/07
Reference Guide
ratioplot6.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_hist
3 ## \notebook
4 ## Example showing a fit residual plot, where the separation margin has been set to 0.
5 ## The last label of the lower plot's y axis is hidden automatically.
6 ## Inspired by the tutorial of Paul Gessinger.
7 ##
8 ## \macro_image
9 ## \macro_code
10 ##
11 ## \author Alberto Ferro
12 
13 import ROOT
14 
15 ROOT.gStyle.SetOptStat(0)
16 
17 c1 = ROOT.TCanvas("c1", "fit residual simple")
18 ROOT.gPad.SetFrameFillStyle(0)
19 
20 h1 = ROOT.TH1D("h1", "h1", 50, -5, 5)
21 h1.FillRandom("gaus", 5000)
22 h1.Fit("gaus", "S")
23 
24 h1.Sumw2()
25 h1.GetXaxis().SetTitle("x")
26 h1.GetYaxis().SetTitle("y")
27 
28 rp1 = ROOT.TRatioPlot(h1, "errfunc")
29 rp1.SetGraphDrawOpt("L")
30 rp1.SetSeparationMargin(0.0)
31 rp1.Draw()
32 rp1.GetLowerRefGraph().SetMinimum(-2)
33 rp1.GetLowerRefGraph().SetMaximum(2)
34 
35 c1.Update()