Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
hist029_TRatioPlot_simple.py
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
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] )")
24
25h1.FillRandom(f1, 1900)
26h2.FillRandom(f1, 2000)
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)
38c1.Draw()
39rp.Draw()
40
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.