# Histogram stack not updating axis limits automatically

**URL:** <https://root-forum.cern.ch/t/histogram-stack-not-updating-axis-limits-automatically/58100>\
**Category:** Newbie\
**Created:** [February 8, 2024, 12:46pm UTC](https://root-forum.cern.ch/t/histogram-stack-not-updating-axis-limits-automatically/58100 "2024-02-08T12:46:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [February 8, 2024, 12:46pm UTC](https://root-forum.cern.ch/t/histogram-stack-not-updating-axis-limits-automatically/58100/1 "2024-02-08T12:46:49Z")

</div>

Hello users,

I am trying to adjust the limits of a Histogram stack

```auto
{
    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
```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 8, 2024, 1:42pm UTC](https://root-forum.cern.ch/t/histogram-stack-not-updating-axis-limits-automatically/58100/2 "2024-02-08T13:42:06Z")

</div>

Can you provide a running example ?

---

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [February 9, 2024, 5:33am UTC](https://root-forum.cern.ch/t/histogram-stack-not-updating-axis-limits-automatically/58100/3 "2024-02-09T05:33:36Z")

</div>

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.
