Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
twoscales.py File Reference

Detailed Description

View in nbviewer Open in SWAN
Example of macro illustrating how to superimpose two histograms with different scales in the "same" pad.

Inspired by work of Rene Brun.

#include "TCanvas.h"
#include "TStyle.h"
#include "TH1.h"
#include "TGaxis.h"
#include "TRandom.h"
import ROOT
c1 = ROOT.TCanvas("c1","hists with different scales",600,400)
h1 = ROOT.TH1F("h1","my histogram",100,-3,3)
for i in range(10000) :
hint1 = ROOT.TH1F("hint1","h1 bins integral",100,-3,3)
sum = 0
for i in range(1,101) :
sum += h1.GetBinContent(i)
rightmax = 1.1*hint1.GetMaximum()
scale = ROOT.gPad.GetUymax()/rightmax
hint1.Draw("same")
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.
Author
Alberto Ferro

Definition in file twoscales.py.