Plotting with two scales

My data is in an ntuple, and there’s three plots I want. They all are plotted against time (effectively, actually their run number but that’s besides the point).

One is a raw rate straight from experimental data, the next is a corrected rate based on atmospheric pressure, and the last is the atmospheric pressure.

I currently can plot rate & corrected rate easily, and I tried several methods to allow myself to be able to use the tutorial’s method for plotting with two different scales, but I couldn’t manage it.

Currently I use:

data->SetMarkerColor(kRed); data->Draw("rateraw:run", domoptions.str().c_str(), ""); data->SetMarkerColor(kBlue); data->Draw("ratecorr:run", domoptions.str().c_str(), "same");
Where domoptions is a stringstream that just selects which parts of the data to use. (I need to make 160 of these plots but I think starting with one is a good idea)

My idea was to use “prof” in the third argument to convert it into a 1d histogram, as well as for the pressure, but frankly I failed miserably.

Am I going about in the right direction? If not what method should I go about doing?

Thanks
Matt

The example showing how to have two scales on the same plot is:

$ROOTSYS/tutorials/hist/twoscales.C

Sorry, I thought I mentioned that I am attempting to follow that example but it will only work in 1d histograms.

I’m dealing with TH2s and the trouble mostly comes from the fact that I need two of them.

To elaborate further, I tried attempting something along the lines of

data->Draw("rateraw:run>>h1", domoptions.str().c_str(), "prof")
data->Draw("ratecorr:run>>h2", domoptions.str().c_str(), "prof")
data->Draw("pressure:run>>h3", domoptions.str().c_str(), "prof")

then scaling h3 using the methods described in the example but I ended with a blank picture after plotting like

h1->Draw()
h2->Draw("same")
h3->Draw("same")

I hope that helps

example:

{
   TCanvas *c1 = new TCanvas("c1","c1",600,600);
   TPad *pad1 = new TPad("pad1","",0,0,1,1);
   TPad *pad2 = new TPad("pad2","",0,0,1,1);
   pad2->SetFillStyle(4000); //will be transparent  
   pad2->SetFrameFillStyle(0);


   TH2F *h1 = new TH2F("h1","h1",40,-4,4,40,-4,4);
   TH2F *h2 = new TH2F("h2","h2",40,-40,40,40,-40,40);
   Double_t a,b;
   for (Int_t i=0;i<5000;i++) {
      gRandom->Rannor(a,b);
      h1->Fill(a-1.5,b-1.5);
      h2->Fill(10*a+1.5,10*b+1.5);
   }

   pad1->Draw();
   pad1->cd();  
   h1->Draw("");

   pad2->Draw();
   pad2->cd();
   h2->SetMarkerColor(kRed);  
   h2->Draw("X+Y+");  
}