{ gROOT->Reset(); 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","my pad 1",0,0,1,1); TPad *pad2 = new TPad("pad2","my pad 2",0,0,1,1); pad2->SetFillStyle(4000); //will be transparent pad1->Draw(); pad1->cd(); // Draw the first graph with axis (A) and Smooth Curve (C) inputSpec->Draw("AC"); gPad->Update(); TH1F *h2 = inputSpec2->GetHistogram(); TAxis *Ay2 = h2->GetYaxis(); Ay2->SetRangeUser(0.0, 0.5); pad2->Draw(); pad2->cd(); inputSpec2->SetLineColor(kRed); // Smooth curve (C) with Marker (P), try AY+ // AY+ clears the previous graph inputSpec2->Draw("CP"); Double_t pad1x[2], pad1rax[2]; Double_t xy[4]; pad1->GetRange(xy[0], xy[1], xy[2], xy[3]); pad1x[0] = xy[0]; pad1x[1] = xy[2]; printf("pad1 Range = %f %f %f %f\n", xy[0],xy[1],xy[2],xy[3]); pad1->GetRangeAxis(xy[0],xy[1],xy[2],xy[3]); pad1rax[0] = xy[0]; pad1rax[1] = xy[2]; printf("pad1 RangeAxis = %f %f %f %f\n", xy[0],xy[1],xy[2],xy[3]); // Set values; printf("%f %f\n", pad1x[0], pad1x[1]); //compute the pad range with suitable margins Double_t ymin = 0; Double_t ymax = 0.5; Double_t dy = (ymax-ymin)/0.8; //10 per cent margins top and bottom // pad2->Range(xmin-0.1*dx,ymin-0.1*dy,xmax+0.1*dx,ymax+0.1*dy); pad2->Range( pad1x[0], ymin-0.1*dy, pad1x[1], ymax+0.1*dy); pad2->RangeAxis( pad1rax[0], 0.0, pad1rax[1], 0.5); pad2->Update(); pad2->GetRange(xy[0],xy[1],xy[2],xy[3]); printf("pad2 Range = %f %f %f %f\n", xy[0],xy[1],xy[2],xy[3]); pad2->GetRangeAxis(xy[0],xy[1],xy[2],xy[3]); printf("pad2 RangeAxis = %f %f %f %f\n", xy[0],xy[1],xy[2],xy[3]); //draw an axis on the right side // Use the size of the pad as the first 4 arguments. // xmin, ymin, xmax, ymax // wmin, wmax, ndiv, chopt // wmin - XOrigin in WC space // wmax - XEnd in WC space // ndiv = N1 + 100*N2 + 10000*N3 // where N1 = number of 1st divisions // N2 = number of second divisions // N3 = number of thrid divisions. // eg in this case 5 third divisions, 1 second and zero first. // // +L - (+) draw tick marks on positive side. // (L) labels are left justified // TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymax(), 0,0.5,510,"+L"); axis->SetLineColor(kRed); axis->SetTextColor(kRed); axis->Draw("G"); }