# How to increase the tick length in TGraph2D?

**URL:** <https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440>\
**Category:** Newbie\
**Created:** [November 20, 2022, 4:21am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440 "2022-11-20T04:21:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [November 20, 2022, 4:21am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/1 "2022-11-20T04:21:32Z")

</div>

Hi,  
I have tried using GetXaxis().SetTickLength() to increase the tick length but it’s not working. Is there any other way to increase the tick length in TGraph2D() ?

_ROOT Version:_ 5.34/09  
_Platform:_ Scientific Linux

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [November 20, 2022, 4:41am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/2 "2022-11-20T04:41:06Z")

</div>

Try `graph->GetHistogram()->GetXaxis()->SetTickLength(yourvalue)` after drawing it.

---

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [November 20, 2022, 4:47am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/3 "2022-11-20T04:47:42Z")

</div>

It is not working, though it’s not showing any error.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [November 20, 2022, 5:01am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/4 "2022-11-20T05:01:32Z")

</div>

Then it’s better if you show a minimal reproducer, something that we can run, or the code you are using, and what exactly you get.

---

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [November 20, 2022, 5:53am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/5 "2022-11-20T05:53:12Z")

</div>

```auto
c = TCanvas("Noise","Graph2d",0,0,700,600)
dt = TGraph2d()
x = np.linspace(0,1,40)
y = np.linspace(0,1,40)
k = 0
for i in range(40):
     for j in range(40):
          dt.SetPoint(k, x[i], y[j], Noise[i][j])
          k = k + 1
dt.SetTitle(" ; x ; y ; ")
dt.Draw("colz")
dt.GetHistogram().GetXaxis().SetTickLength(1.5)
dt.GetHistogram().GetXaxis().SetTickLength(1.5)
c.Write()

```

Here Noise is a 2D array of dimension 40x40

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [November 20, 2022, 6:03am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/6 "2022-11-20T06:03:11Z")

</div>

That code doesn’t run as-is, but at least add this

```auto
c.Modified()
c.Update()

```

after doing all the SetTickLength lines. It will probably work without Modified(), but keep it just to be safe.

---

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [November 20, 2022, 6:09am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/7 "2022-11-20T06:09:34Z")

</div>

Still not working.  
Is this due to the version of the ROOT that I am working with ?

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [November 20, 2022, 6:18am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/8 "2022-11-20T06:18:27Z")

</div>

I don’t know. For me it works fine with th latest ROOT, and I cannot use ROOT 5 wth Python on Windows, so I cannot test.  
But what exactly do you mean by “not working”? what do you get? what is the full code you are trying? Do you see anything if you don’t Write the canvas, just keep the canvas window open (add an “input” line instead of Write)?

---

<div class="post-metadata">

**Author:** ![Songshaptak\_De](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/songshaptak_de/32/27468_2.png) [@Songshaptak\_De](https://root-forum.cern.ch/u/Songshaptak_De)\
**Post date:** [November 20, 2022, 6:22am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/9 "2022-11-20T06:22:29Z")

</div>

By “not working”, I mean I am getting all the expected plots and labels, but I want to increase the tick length and using the command that you have suggested or that I was using earlier, I am not seeing any change in the tick length even though the expected plot gets created

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [November 20, 2022, 6:53am UTC](https://root-forum.cern.ch/t/how-to-increase-the-tick-length-in-tgraph2d/52440/10 "2022-11-20T06:53:53Z")

</div>

Try the first example in the [TGRaph2D Documentation](https://root.cern/doc/master/classTGraph2D.html); instead of “surf1”, draw with “colz”, as you are trying to do; and add your SetTickLength line. For me it works (without even Updating the canvas) as expected with ROOT 5.34/38 on Windows; 1.5 is too big for the ticks, but you can see it works.

```auto
   TCanvas *c = new TCanvas("c","Graph2D example",0,0,600,400);
   Double_t x, y, z, P = 6.;
   Int_t np = 200;
   TGraph2D *dt = new TGraph2D();
   dt->SetTitle("Graph title; X axis title; Y axis title; Z axis title");
   TRandom *r = new TRandom();
   for (Int_t N=0; N<np; N++) {
      x = 2*P*(r->Rndm(N))-P;
      y = 2*P*(r->Rndm(N))-P;
      z = (sin(x)/x)*(sin(y)/y)+0.2;
      dt->SetPoint(N,x,y,z);
   }
   gStyle->SetPalette(1);
   dt->Draw("colz");
   dt->GetHistogram()->GetXaxis()->SetTickLength(1.5);

```

![c](https://root-forum.cern.ch/uploads/default/original/3X/2/4/249cd70b4bae3aada848e908fd44550dfef1608f.png)

If that doesn’t work there may be other issues. Maybe try reinstalling, or another ROOT version.
