# Unable to set the x axis range of a TGraph

**URL:** <https://root-forum.cern.ch/t/unable-to-set-the-x-axis-range-of-a-tgraph/58751>\
**Category:** Newbie\
**Created:** [March 27, 2024, 11:58am UTC](https://root-forum.cern.ch/t/unable-to-set-the-x-axis-range-of-a-tgraph/58751 "2024-03-27T11:58:17Z")\
**Posts on this page:** 2\
**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:** [March 27, 2024, 11:58am UTC](https://root-forum.cern.ch/t/unable-to-set-the-x-axis-range-of-a-tgraph/58751/1 "2024-03-27T11:58:17Z")

</div>

Hi all,  
I cannot set the x-axis range of the TGraphError below using the SetRangeUser() method.  
I am almost sure I am doing something ridiculous, but can someone please help me figure that out ?  
Everytime I get the same axis range from about 1140. 1240.

```auto

void increase_axis(){
	
	TCanvas *c1 = new TCanvas("c1","c1");
	
        const int n = 3;
        double x[n]= {1148, 1186.5, 1229.9};
        double y[n]= {640.61, 731.72, 756.98};
        double err_y[n] = {27.16, 22.98 , 51.83};
       
   
	auto g = new TGraphErrors(n,x,y,nullptr, err_y);
	g->Draw("ap");
  	g->GetXaxis()->SetRangeUser(00, 1400);
        
        gPad->Update();
        gPad->Modified();
  	
}
Thanks a lot

```

---

<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:** [March 27, 2024, 12:29pm UTC](https://root-forum.cern.ch/t/unable-to-set-the-x-axis-range-of-a-tgraph/58751/2 "2024-03-27T12:29:04Z")

</div>

SetRange and SetRangeUser access the underlying histogram used to draw axis. They can only zoom, not unzoom (ie: increase the scales). The way to do it is:

```auto
void increase_axis(){
   auto c1 = new TCanvas("c1","c1");
   const int n = 3;
   double x[n]= {1148, 1186.5, 1229.9};
   double y[n]= {640.61, 731.72, 756.98};
   double err_y[n] = {27.16, 22.98 , 51.83};
   c1->DrawFrame(0., 580., 1400, 850);
   auto g = new TGraphErrors(n,x,y,nullptr, err_y);
   g->Draw("p");
}

```
