# Accessing labels of secondary tick marks

**URL:** <https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218>\
**Category:** ROOT\
**Tags:** graphics, hist, root\
**Created:** [July 16, 2024, 10:43am UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218 "2024-07-16T10:43:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lidakal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lidakal/32/37103_2.png) [@lidakal](https://root-forum.cern.ch/u/lidakal)\
**Post date:** [July 16, 2024, 10:43am UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218/1 "2024-07-16T10:43:26Z")

</div>

Hello everyone,

I am having trouble accessing the labels of secondary tick marks in a log axis. In practice, I would like to keep the primary tick mark labels, and _some_ of the secondary ones. I provide an example below:

```auto
    TH1D *h = new TH1D("h", "some histogram", 5, 0, 2.1);
    for (int i=0; i<5; i++) {
        for (int j=0; j<=i; j++) h->Fill(i*0.42);
    }
    h->GetXaxis()->SetTitle("ln(0.4/x)");

    TCanvas *c = new TCanvas("c", "second axis", 800, 600);
    h->Draw();

    c->SetBottomMargin(0.3);

    auto axis = new TGaxis(2.1, 0.02, 0. ,0.02, 0.048982571, 0.4, 2,"NIGS-");
    axis->SetTitle("x");
    axis->CenterTitle();
    axis->SetTitleFont(43);
    axis->SetTitleSize(20);
    axis->SetTitleOffset(1.2);
    axis->SetLabelFont(43);
    axis->SetLabelSize(20);
    axis->SetLabelOffset(0.05);
    axis->SetTickSize(0.02);
    axis->SetMoreLogLabels(); // add the secondary tick labels
    // axis->ChangeLabel(1,-1,-1,-1,-1,-1,"-#pi");
    axis->ChangeLabel(510,-1,-1,-1,-1,-1,"this");
    axis->SetNoExponent();
    axis->Draw();

```

So the second axis is a log axis, where I want to keep from the secondary tick labels the 0.4, 0.3, 0.2 and 0.05, and get rid of the ones between 0.05 and 0.1, but with ChangeLabel() so far I have only managed to access the primary tick mark 0.1.

I am using ROOT 6.14 and can easily access up to 6.28.

Thanks in advance,  
Lida

_ROOT Version:_ 6.14  
_Platform:_ Centos 7

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 16, 2024, 3:16pm UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218/2 "2024-07-16T15:16:17Z")

</div>

Hi Lida,

You can try to “erase” axis labels providing `labSize` argument 0:

```auto
    axis->ChangeLabel(1,-1,0);
    axis->ChangeLabel(2,-1,0);

```

Here `1` and `2` are labels indexes. See more info in [documentation](https://root.cern/doc/master/classTGaxis.html#aba963a2d24a0aa2e53ad01684a77b2f5)

In newer ROOT versions you also can modify axis labels by its values:

```auto
    axis->ChangeLabelByValue(0.05,-1,0);
    axis->ChangeLabelByValue(0.06,-1,0);

```

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![lidakal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lidakal/32/37103_2.png) [@lidakal](https://root-forum.cern.ch/u/lidakal)\
**Post date:** [July 17, 2024, 4:48pm UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218/3 "2024-07-17T16:48:53Z")

</div>

Dear Sergey,

Thanks for your response.

Unfortunately, ChangeLabel() has only worked for the primary tick marks in version 6.14. Meaning ChangeLabel(1,-1,0) affects the 0.1 label in the example above. I tried accessing the secondary labels with labNum=100 following the ndiv numbering scheme but it didn’t work.

I ended up installing version 6.30 on my own machine and I see that ChangeLabel(1, -1, 0) in this version actually affects the rightmost label (0.05) instead. Odd change from version to version.

I would really like to replicate this behavior in version 6.14 if possible, as it is the version on the machine at my institute.

Cheers,  
Lida

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 17, 2024, 5:46pm UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218/4 "2024-07-17T17:46:17Z")

</div>

Hi,

Version 6.14 is really old and most probably has bugs - which were fixed afterwards.

The only I can recommend - try experimentally which `labNum` value suppress labels.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![lidakal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lidakal/32/37103_2.png) [@lidakal](https://root-forum.cern.ch/u/lidakal)\
**Post date:** [July 18, 2024, 8:26am UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218/5 "2024-07-18T08:26:45Z")

</div>

Hi Sergey,

Thanks for your help. I will probably end up doing the cosmetic changes on a newer version.

Best,  
Lida

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 1, 2024, 8:27am UTC](https://root-forum.cern.ch/t/accessing-labels-of-secondary-tick-marks/60218/6 "2024-08-01T08:27:13Z")

</div>

Closed on August 1, 2024, 8:27am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
