Updating the axis range in a sub pad

From: Ida Häggström <ida.haggstrom_at_radfys.umu.se>
Date: Tue, 4 Oct 2011 16:19:47 +0200


Hello!
I have a macro that analyzes a ROOT tree file in which I make a drawing of 6 different histograms in one canvas. I want to manually set the x- and y-axis range of a couple of the pads on the canvas, but I can't get it right it seems! Here's a trimmed code snippet:


   TH2F *hist1= new TH2F("hist1","Transaxial detection position",252,-505.,+505.,252,-505.,+505.);

   TH1F *hist2= new TH1F("hist2","Axial detection position",100.,-100.,+100.);

   TH1F *hist3= new TH1F("hist3","Isotope decay",100,0,500);
   TH1F *hist4= new TH1F("hist4","Axial sensitivity",100,-100.,+100.);
   TH1F *hist5= new TH1F("hist5","Axial scatter fraction",100,-100.,+100.);
   TH1F *hist5a= new TH1F("hist5a","Axial scatters
distribution",100,-100.,+100.);

   TH1F *hist5b = new TH1F("hist5b","",100,-100.,+100.);    TH1F *hist6= new TH1F("hist6","Isotope decay 2",100,0,500);

// New canvas

   c1 = new TCanvas("c1","TEST",3,28,970,632);    Int_t pos=1;

   c1->Divide(3,2);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);

// First pad

   c1->cd(pos++);
   hist1->Draw();
// Second pad

   c1->cd(pos++);
   hist2->Draw();
// Third pad

   c1->cd(pos++);
   hist3->Draw();
   tex = new TLatex(10.,(int)(hist3->GetMaximum()/2.),"Some text");    tex->Draw();
   tex = new TLatex(10.,(int)(hist3->GetMaximum()/2.*0.8),"Some other text");

   tex->Draw();
// Fourth pad

   c1->cd(pos++);
   hist4->Draw();
// Fifth pad

   c1->cd(pos++);
   hist5->Divide(hist5a,hist5b,1.,1.,"");    hist5->Draw();
// Sixth pad

   c1->cd(pos++);
   hist6->Draw();
   tex2 = new TLatex(10.,(int)(hist6->GetMaximum()/2.),"Some text");    tex2->Draw();
   tex2 = new TLatex(10.,(int)(hist6->GetMaximum()/2.*0.8),"Some other text");

   tex2->Draw();

// Setting x- and y-axes...

   c1->GetPad(3)->GetFrame()->SetY1(0);
   c1->GetPad(3)->GetFrame()->SetX2(500);
   c1->GetPad(6)->GetFrame()->SetY1(0);
   c1->GetPad(6)->GetFrame()->SetX2(500);

// Update canvas

   c1->Update();


The axis range commands under "// Setting x- and y-axes... " don't seem to do anything. How can I set these values and properly update the canvas? Any ideas? Thanks!
/Ida Received on Tue Oct 04 2011 - 16:19:55 CEST

This archive was generated by hypermail 2.2.0 : Tue Oct 04 2011 - 17:50:01 CEST