Add an Axis

Hey,

I have code that writes two graphs on a single canvas at once. The problem is the two graphs require different yaxes. How can I add an axis to the right side of the graph to display the proper y axis for the second set of data?

Thanks in advance for any help.

See if this helps: ROOT Tutorial: Superimposing two histograms with two different scales
http://root.cern.ch/root/html/examples/twoscales.C.html
Output of tutorial:

Note also that the options X+ and Y+ described here:
root.cern.ch/root/html/THistPainter.html#HP01a
can be used to display the axis on the right side or top side instead of using TGaxis.
Here is an example:

{
   TCanvas *c1 = new TCanvas("c1","c1",200,10,700,500);

   TPad *pad1 = new TPad("pad1","",0,0,1,1);
   TPad *pad2 = new TPad("pad2","",0,0,1,1);
   pad2->SetFillStyle(0);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameFillColor(0);

   pad1->SetLogy();
   pad2->SetLogy();


   const Int_t n = 20;
   Double_t x[n], y1[n], y2[n];
   for (Int_t i=0;i<n;i++) {
     x[i] = i*0.1+5;
     y1[i] = 100000*sin(x[i]+0.2);
     y2[i] = 100000*cos(x[i]+0.2);
   }

   gr1 = new TGraph(n,x,y1);
   gr1->SetMarkerStyle(21);
   gr2 = new TGraph(n,x,y2);
   gr2->SetMarkerStyle(20);


   pad1->Draw();
   pad1->cd();
   gr1->Draw("APL");

   pad2->Draw();
   pad2->cd();
   gr2->Draw("APL Y+");
}