X-axis Ranges using THStack

Hello,

I am trying to overlay two histograms on two different TPads using THStack. I am trying to change the range of the histograms in the stack, however, only the second range is changing. Here’s an example that creates a canvas, divides it into two parts (p1 and p2) and places the hists (hist1 and hist2) on each canvas. The hists on p2 have the correct range however the hists on p1 do not have changed ranges:


TCanvas *can = new TCanvas("can","can",10,10,800,600);
can->Divide(2);
	for (int j = 0; j < 2; j++) {
		can->cd(j+1);
		THStack* hs = new THStack("hs","Hist Stack Example");
		hs->Add(hist1);
		hs->Add(hist2);
		hs->Draw("nostack");
		hs->GetXaxis()->SetRangeUser(xmin,xmax);
	}

In your code the histograms hist1 and hist2 are not defined.
Can you send a running script showing your problem ?
Thanks in advance.