Hi Gerco, You will find below an example of macro showing a possible solution. It will part of the tutorials section. Rene Brun void two() { //example of macro illustrating how to superimpose two histograms //with different scales in the "same" pad. TCanvas *c1 = new TCanvas("c1","example of two overlapping pads",600,400); //create/fill draw h1 gStyle->SetOptStat(kFALSE); TH1F *h1 = new TH1F("h1","my histogram",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 TH1F *hint1 = new TH1F("hint1","h1 bins integral",100,-3,3); Float_t sum = 0; for (i=1;i<=100;i++) { sum += h1->GetBinContent(i); hint1->SetBinContent(i,sum); } //scale hint1 to the pad coordinates Float_t rightmax = 1.1*hint1->GetMaximum(); Float_t scale = gPad->GetUymax()/rightmax; hint1->SetLineColor(kRed); hint1->Scale(scale); hint1->Draw("same"); //draw an axis on the right side TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L"); axis->SetLineColor(kRed); axis->SetTextColor(kRed); axis->Draw(); } Gerco Onderwater wrote: > > Hi Rooters, > > Probably this is somewhere in the tutorials, but I haven't been able to > find where. > > What I would like to do is plot two TH1D's with the same x-axes, > but with different y-axes on top of each other. One of the two should then > refer to the left y-axis and the other to the right one (which should also > have ticks and a title of course). How do I do that? > > Thanks, > > -- Gerco > > Dr. C.J.G. Onderwater > Nuclear Physics Laboratory > 312 Loomis Laboratory of Physics > University of Illinois at Urbana-Champaign > 1110 West Green Street > Urbana, IL 61801-3080 > Phone : (217) 244-7363 > Fax : (217) 333-1215 > E-mail: onderwat@uiuc.edu
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET