I have two histograms. I plotted one histogram and using TGaxis I added one new x axis on the top of the pad. My second histogram is for that new axis. How do I plot second histogram on the same pad. More specifically, My first histogram has x axis from -10 to 10 and my second histogram has x axis from 0 to 100.When I plot second histogram it is shown up to 10 not up to 100.Y axis in both is just counts. In one sense -10 of first histogram corresponds to 0 for second histogram.
This is the process I used
TCanvas *c= new TCanvas();
r1->Draw();//r1 is my first histogram from -10 to 10
TF1 *f1 = new TF1("f1","x",0,100);
TGaxis *A = new TGaxis(-10,25,10,25,"f1",10,"+",5);
A->Draw();
r2->Draw("hist same");//r2 is my second histogram
Try (you will need to “convert” it to use histograms instead of graphs):
BTW. Maybe you simply want:
{
TCanvas *c = new TCanvas("c", "c");
c->DrawFrame(-10, 0., 100., 25., "My Title;My X;My Y"); // draw the frame
TF1 *f1 = new TF1("f1", "x", 0., 100.);
f1->Draw("SAME"); // draw the function
r1->Draw("HIST SAME"); // r1 is my first histogram from -10 to 10
r2->Draw("HIST SAME"); // r2 is my second histogram
}