Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
twoscales.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_hist
3## \notebook
4## Example of macro illustrating how to superimpose two histograms
5## with different scales in the "same" pad.
6## Inspired by work of Rene Brun.
7##
8## \macro_image
9## \macro_code
10##
11## \author Alberto Ferro
12
13#include "TCanvas.h"
14#include "TStyle.h"
15#include "TH1.h"
16#include "TGaxis.h"
17#include "TRandom.h"
18
19import ROOT
20
21c1 = ROOT.TCanvas("c1","hists with different scales",600,400)
22
24
25h1 = ROOT.TH1F("h1","my histogram",100,-3,3)
26
27for i in range(10000) :
29
30h1.Draw()
32
33hint1 = ROOT.TH1F("hint1","h1 bins integral",100,-3,3)
34
35sum = 0
36for i in range(1,101) :
37 sum += h1.GetBinContent(i)
39
40rightmax = 1.1*hint1.GetMaximum()
41scale = ROOT.gPad.GetUymax()/rightmax
43hint1.Scale(scale)
44hint1.Draw("same")
45
47 ROOT.gPad.GetUxmax(), ROOT.gPad.GetUymax(),0,rightmax,510,"+L")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.