Histogram stack not updating axis limits automatically

Hello users,

I am trying to adjust the limits of a Histogram stack

{
    TCanvas* c = new TCanvas("c","c",1500,800);
	Double_t eps = 0.005;
	TPad* p1 = new TPad("p1","p1",0.1,0.5,0.9,0.9,0); p1->Draw();
	TPad* p2 = new TPad("p1","p1",0.1,0.1,0.9,0.5+eps,0); p2->Draw();
	p1->SetBottomMargin(0);
	p2->SetTopMargin(0);   
	
	p1->cd();
	
	hstack1->Draw("plc nostack"); //palete line color, automatic
	hstack1->GetXaxis()->SetLimits(50, 1050);
	p1->Update();
	
	p2->cd();
	
	hstack2->Draw("plc nostack"); //palete line color, automatic
	hstack2->GetXaxis()->SetLimits(50, 1050);
	p2->Update();
    c->cd();
}

However, after drawn the ThStack I have to click inside the canvas or maximize it for the axis limits to take place, can someone please share what I am missing here.
It will be amazing if the range is set without the need to click/maximize?

Thanks a lot for your patience an time

Can you provide a running example ?

Yes, sure, currently it is directly drawing the histos from a root file. But I guess I can try reproducing it by dummy histograms and sharing minimal working example.

1 Like