# How to increase axis length

**URL:** <https://root-forum.cern.ch/t/how-to-increase-axis-length/41789>\
**Category:** Newbie\
**Created:** [October 9, 2020, 12:50pm UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789 "2020-10-09T12:50:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhil\_bhathi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@nikhil\_bhathi](https://root-forum.cern.ch/u/nikhil_bhathi)\
**Post date:** [October 9, 2020, 12:50pm UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789/1 "2020-10-09T12:50:10Z")

</div>

I am trying to use TGraph and TMultiGraph classes.  
The issue is I want to increase the length of x and Y axis. How do I do that?

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [October 9, 2020, 1:09pm UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789/2 "2020-10-09T13:09:24Z")

</div>

Hi @nikhil_bhathi,  
the `SetRange` and `SetRangeUser` methods change the axes ranges (e.g. `graph.GetXaxis()->SetRangeUser(min, max)`). See the documentation of [TAxis](https://root.cern/doc/master/classTAxis.html), which is what `GetXaxis` and `GetYaxis` return.

If you can provide a small snippet of code that should do what you want but does not we can probably help further.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![nikhil\_bhathi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@nikhil\_bhathi](https://root-forum.cern.ch/u/nikhil_bhathi)\
**Post date:** [October 9, 2020, 1:55pm UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789/3 "2020-10-09T13:55:36Z")

</div>

Hi @eguiraud ,  
Thank you for your reply.  
I tried the code but it didn’t work.  
I am also unable to use TLegend class(it is commented). Could you take a look at this too?  
Thank you  
[ArCu6.c](https://root-forum.cern.ch/uploads/short-url/yrvI2PZuItVeC0TRWEIwUwQMI7v.c) (526 Bytes)

---

<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:** [October 12, 2020, 1:39pm UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789/4 "2020-10-12T13:39:30Z")

</div>

Missing files:

```auto
Processing ArCu6.c...
Error in <TGraph::TGraph>: Cannot open file: Ar6.txt, TGraph is Zombie
Error in <TGraph::TGraph>: Cannot open file: Cu6.txt, TGraph is Zombie

```

---

<div class="post-metadata">

**Author:** ![nikhil\_bhathi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@nikhil\_bhathi](https://root-forum.cern.ch/u/nikhil_bhathi)\
**Post date:** [October 13, 2020, 8:33am UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789/5 "2020-10-13T08:33:45Z")

</div>

Hi @couet  
I am sorry I forgot to insert them.  
Here they are.[Ar6.txt](https://root-forum.cern.ch/uploads/short-url/1MgGorBMybDVN2ME6SOnGbwbMkW.txt) (16.4 KB) [Cu6.txt](https://root-forum.cern.ch/uploads/short-url/fOL7fuMWXvRMPb8mWpbfVfFATeq.txt) (17.3 KB)

---

<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:** [October 13, 2020, 9:03am UTC](https://root-forum.cern.ch/t/how-to-increase-axis-length/41789/6 "2020-10-13T09:03:25Z")

</div>

```auto
void ArCu6()
{

   TGraph *Ar = new TGraph("Ar6.txt");
   Ar->SetLineColor(kBlue);

   TGraph *Cu = new TGraph("Cu6.txt");
   Cu->SetLineColor(kRed);

   TMultiGraph *Mg = new TMultiGraph();
   Mg->Add(Ar);
   Mg->Add(Cu);

   Mg->GetXaxis()->SetTitle("#theta_{Lab} (deg)");
   Mg->GetYaxis()->SetTitle("Energy (MeV/u)");
   Mg->GetXaxis()->CenterTitle();
   Mg->GetYaxis()->CenterTitle();

   Mg->GetXaxis()->SetLimits(0.,2.);
   Mg->Draw("AC");

   TLegend *lg = new TLegend (.7,.8,.9,.9);
   lg->AddEntry(Ar,"40^{Ar}","l");
   lg->AddEntry(Cu,"59^{Cu}","l");
   lg->Draw();
}

```

I modified the macro in order to show the legend (it was not drawn).  
And the axis limits should be changed (not the range).

 ![Screenshot 2020-10-13 at 11.04.58](https://root-forum.cern.ch/uploads/default/original/3X/f/b/fb1e44fb4fc0032b1c5da2e97f3864d48c86c43f.jpeg)
