Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
13import ROOT
14
15ROOT.gStyle.SetOptStat(0)
16
17c1 = ROOT.TCanvas("c1", "fit residual simple")
18ROOT.gPad.SetFrameFillStyle(0)
19
20h1 = ROOT.TH1D("h1", "h1", 50, -5, 5)
21h1.FillRandom("gaus", 5000)
22h1.Fit("gaus", "S")
23
24h1.Sumw2()
25h1.GetXaxis().SetTitle("x")
26h1.GetYaxis().SetTitle("y")
27
28rp1 = ROOT.TRatioPlot(h1, "errfunc")
29rp1.SetGraphDrawOpt("L")
30rp1.SetSeparationMargin(0.0)
31rp1.Draw()
32rp1.GetLowerRefGraph().SetMinimum(-2)
33rp1.GetLowerRefGraph().SetMaximum(2)
34
35c1.Update()