# Soft limit on axis label offset?

In the TattAxis Class Reference, SetLabelOffset() method is documented to set the axis labels’ offset to be a certain fraction of the pad width.

If this is the case, I would have expected setting it to 0 (or some very small value) would always make the label adhere to the axis line. However, this is not seen to be the exactly the case. Especially For quite “tall” plots, there appears to be a hard limit of how far these labels can be away from the axis, and quite a high limit at that (they are farther away as the plot gets taller).

Here is a screenshot of a trivially simple example I made with 1:2 TCanvas and TH1F with the GetXaxis()->SetLabelOffset(1e-10):

Prefereably, the labels should to be much closer to the axis line, as is possible with a square canvas:

Is there no way to achieve this without drawing a custom TGAxis?

Try with negative offsets, e.g.: `histo->GetXaxis()->SetLabelOffset(-0.01);`

Thank you, that was deceptively simple to do that I hadn’t thought of because I kept thinking in “fraction”…

Just for my own curiosity, is this because there is some “central distance” from the the labels get draw, which is also proportional to the pad width or height?

The central distance is the axis position itself. A positive value of the offset will lower the labels position for horizontal axis and make them more left for vertical and a negative value offset will higher le labels above the axis form horizontal axis and make them more right for vertical.

Apologies for bringing this back up, but I wanted to follow up on this because I wanted to get something working such that I could always have the offset be applied consistently (i.e. same distance from axis) regardless of the canvas size. Is this possible?

Also, if the central distance is the axis position, why is it needed to set a negative value to actually bring the labels (which are originally far away even with 0 offset) back closer to the axis?

I guess what I am asking ultimately here is if there is a way to know where the labels will be drawn given the plotting environment’s attributes such as the pad height and/or the label text size, etc.

Yes just try … if your canvas/pad has de same geometry the offset you apply will appear always the same.

It depends … on which axis ? I would suggest you play interactively with the graphics editor to understand the behaviour.

The description is here. But I guess that’s not enough for you ? The Label offset value in used in TGaxis to paint the labels. For instance line 1474 in the TGaxis code

Hi couet,

Thank you for your pointers, especially to the TGAxis code. Yes, it does seem quite complicated (but I can only fathom needed of course), and maybe if I might want to try playing around with the graphical editor to understand the behaviour and also peer at the code if I want. Thank you again!

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