{ auto c1 = new TCanvas("c1","c1",600,400); // create/fill draw h1 gStyle->SetOptStat(kFALSE); auto h1 = new TH1F("h1","Superimposing two histograms with different scales",100,-3,3); Int_t i; for (i=0;i<10000;i++) h1->Fill(gRandom->Gaus(0,1)); h1->Draw(); c1->Update(); // create hint1 filled with the bins integral of h1 auto hint1 = new TH1F("hint1","h1 bins integral",100,-3,3); float sum = 0.f; for (i=1;i<=100;i++) { sum += h1->GetBinContent(i); hint1->SetBinContent(i,sum); } // scale hint1 to the pad coordinates float rightmax = 1.1*hint1->GetMaximum(); float scale = gPad->GetUymax()/rightmax; hint1->SetLineColor(kRed); hint1->Scale(scale); hint1->Draw("same"); // draw an axis on the right side auto axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L"); axis->SetLineColor(kRed); axis->SetTextColor(kRed); axis->Draw(); }