[ROOT] Superimposing 2D plots from ntuples

From: Robert Lee (leer@london.physics.purdue.edu)
Date: Thu Nov 02 2000 - 01:10:57 MET


Hello all,

   I would like to combine two 2D plots (made from variables 
which were stored in two separate ntuples) with the same X axes
and different Y axes on the same pad.  I tried to follow the
examples I found in earlier posts, but with no luck.  

   When running the portion of the macro below, I only 
get the first plot displayed.  The second axis is generated,
but the scale is not even close to right.  I get no errors
reported as well.

// ************************************ //

 TFile *f1 = new TFile("et0.root");
   TNtuple *ntuple1 = (TTree*)f1->Get("et0");

TFile *f2 = new TFile("et4.root");
   TNtuple *ntuple2 = (TTree*)f2->Get("et4");

 ntuple1->Draw("Xmean:time>>et0x_july", "run_number < 481");
 ntuple2->Draw("Xmean:time>>et4x_july", "run_number < 481");

// make first plot
 et0x_july->SetMarkerColor(4);
 et0x_july->GetXaxis()->SetTitle("Unix Time (sec)");
 et0x_july->GetYaxis()->SetTitle("X ISR Mean (mm)");
 et0x_july->GetYaxis()->CenterTitle();
 et0x_july->SetTitle("July XMean (ISR) vs Time");
 et0x_july->Draw("p");
 myCanvas->Update();

// scale 2nd plot correctly
   Float_t rightmax = 1.1*et4x_july->GetMaximum();
   Float_t scale = gPad->GetUymax()/rightmax;
   et4x_july->Scale(scale);

// draw 2nd plot 
   et4x_july->SetMarkerColor(2);
   et4x_july->Draw("same");

// Draw second axis
   TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
         gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");

   axis->Draw();



// ************************************ //


Thanks !

Robert Lee



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET