Superimpose plots with different y (or x) axis ranges

Hello everybody,
is there any way to superimpose two graphs with different y (or x) axis ranges?
I mean, I would like to get something like http://www.slac.stanford.edu/BFROOT/www/Computing/Offline/ROOT/info/superImposeTwoGraphs.C, but in a simpler way (for example in gnuplot it’s really easy, it supports [xy]1axis and [xy]2axis).

Thanks,
Rene

Try this:

{
   const Int_t N = 10;
   Int_t NMax, in;
   Float_t x[N], y1[N], y2[N], x1, step, dir;
                                                                                
   y1[0] = 5.0;
   y2[0] = 0.1;
   step  = 0.5;
   x[0]  = 0.0;
                                                                                
   for (in=1; inGetHistogram();
   h1->Scale(0.1);
   h1->SetXTitle("X title");
   h1->SetYTitle("Y title");
                                                                                
   TCanvas *c1 = new TCanvas("c1", "Intensity of LED 1",0,  0, 800, 600);
   TPad *pad1 = new TPad("pad1","",0,0,1,1);
   TPad *pad2 = new TPad("pad2","",0,0,1,1);
   pad2->SetFillStyle(4000);    // Makes pad2
   pad2->SetFrameFillStyle(0);  // transparent.
                                                                                
   pad1->Draw();
   pad1->cd();
                                                                                
   inputSpec->Draw("AC");
                                                                                
   TH1F *h2 = inputSpec2->GetHistogram();
   TAxis *Ay2 = h2->GetYaxis();
   Ay2->SetRangeUser(0.0, 0.5);
                                                                                
   pad2->Draw();
   pad2->cd();
                                                                                
   inputSpec2->SetLineColor(kRed);
   inputSpec2->Draw("CPAY+");
}

It does not work, the code seems to be broken.

Yes the copy/paste did not work. sorry. Here is an other example:

{
   ifstream data;
   data.open("led1.data");

   const Int_t n = 100;
   Int_t in = 0;
   Float_t x[n], y1[n], y2[n], x1;

   while (data >> x1)
   {
      x[in] = x1;
      data >> y1[in];
      data >> y2[in];
      in++;
   }

   TGraph *inputSpec = new TGraph(in, x, y1);
   TGraph *inputSpec2 = new TGraph(in, x, y2);

   inputSpec->GetHistogram()->SetXTitle("X title");
   inputSpec->GetHistogram()->SetYTitle("Y title");

   TCanvas *c1 = new TCanvas("c1", "Intensity of LED 1",0,  0, 800, 600);

   inputSpec->Draw("AC");
   gPad->Update();
   inputSpec2->Draw("CP");

   //draw an axis on the right side
  TGaxis *axis = new TGaxis(gPad->GetUxmax(),
                             gPad->GetUymin(),
                             gPad->GetUxmax(),
                             gPad->GetUymax(),
                             0.01,10,510,"+L");
   axis->Draw();
}

file led1.data:

1 1 5
2 2 4
3 3 3
4 4 2
5 5 1
6 4 2
7 3 3
8 2 4
9 1 5