Hello again, thank you very much for your quick response. But I have to say that your suggestion doesn't solve my problem. But that's my fault, because I explained my problem not right. OK, I'll start again. I make the following: - I have a 2 dimensional plot in which on the x-axis a certain cut is shown and on the y-axis a distribution. - I project each slice (corresponding to a certain cut) to have access to one of those distributions - Out of this (now 1 dimensional) projection, I get the 'mean-value' and fill it into another 2 dimensional histogram which shows 'mean-value' vs. cut - Those mean-values can, for some distributions, also be negative. So the origin of the y-axis is shifted above, because ROOT has to show the negative mean-values I filled in. - Now I want to draw a ratio (events under cut)/(events above cut) which tells me for each value of the cut how much statistics I have - I'm only interested in the shape of this ratio. In my case it should be increasing. So I just want to draw this ratio in the same pad. And it should have its origin in the lower left corner of the pad. But my histogram which shows this ratio starts at 0. So when I try to draw the ratio histogram into the same pad in which my 2 dimensional histogram with the negative mean-values is shown, then it is drawn with respect to the origin of the y-axis of the 2 dimensional histogram. My ratio histogram 'hovers' in the pad. I tried to write a little macro to demonstrate the problem. If you execute it, you perhaps won't see entries in the 2 dimensional histogram, but there are 5. In my original problem I have entries with errorbars and I can see them well. But the only interesting in the plots is the red histogram. I hope this will explain my problem. Int_t Example() { // simulating several distributions TF1* sqr1 = new TF1("sqr1","70-(x+5)*(x+5)",-10,10); TF1* sqr2 = new TF1("sqr2","70-(x+3)*(x+3)",-10,10); TF1* sqr3 = new TF1("sqr3","70-(x+0)*(x+0)",-10,10); TF1* sqr4 = new TF1("sqr4","70-(x-3)*(x-3)",-10,10); TF1* sqr5 = new TF1("sqr5","70-(x-6)*(x-6)",-10,10); // fill histograms randomly to get the mean values TH1F* h1f = new TH1F("h1f","Test random numbers",200,-10,10); h1f->FillRandom("sqr1",10000); TH1F* h2f = new TH1F("h2f","Test random numbers",200,-10,10); h2f->FillRandom("sqr2",10000); TH1F* h3f = new TH1F("h3f","Test random numbers",200,-10,10); h3f->FillRandom("sqr3",10000); TH1F* h4f = new TH1F("h4f","Test random numbers",200,-10,10); h4f->FillRandom("sqr4",10000); TH1F* h5f = new TH1F("h5f","Test random numbers",200,-10,10); h5f->FillRandom("sqr5",10000); TH2F* h2 = new TH2F("h2","h2", 5, 0, 5, 200, -10, 10); TH1F* h3 = new TH1F("h3","h3", 5, 0, 5); // get the mean values and fill them into a 2-dim histogram Float_t mean1 = h1f->GetMean(); h2->Fill(0.5, mean1); Float_t mean2 = h2f->GetMean(); h2->Fill(1.5, mean2); Float_t mean3 = h3f->GetMean(); h2->Fill(2.5, mean3); Float_t mean4 = h4f->GetMean(); h2->Fill(3.5, mean4); Float_t mean5 = h5f->GetMean(); h2->Fill(4.5, mean5); // simulate the ratio histogram which should be drawn into the same pad // as the 2 dimensional histogram for (Size_t i = 1; i <= 5; ++i){ h3->Fill(i, ((i)*5.7)); } h3->SetFillColor(0); h3->SetLineColor(kRed); TCanvas* c2 = new TCanvas("c2","c2",1); c2->Divide(2); // draw the original shape c2_1->cd(); h3->Draw(); // draw what happens // but I would like to have the red line starting in the lower left corner // of the pad like it is shown in pad c2_1 c2_2->cd(); h2->Draw(); c2_2->Update(); // create the second axis like in the tutorial Float_t rightmax = 1.1*h3->GetMaximum(); Float_t scale = gPad->GetUymax()/rightmax; h3->Scale(scale); h3->Draw("same"); TGaxis* axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymax(), 0, rightmax, 510, "+L"); axis->SetLineColor(kRed); axis->SetTextColor(kRed); axis->SetLabelColor(kRed); axis->SetTitle("ratio"); axis->Draw(); } I hope it's more obvious now.
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:44 MET