Meaning of pad margin

Hi experts,

I’m interested in finding out the actual meaning of pad margins in regards to plotting. While they seem to be the distance between the edge of the pad and the histogram axes, when the axes have labels this relationship is broken. It’s not clear how can I obtain the actual distance between axis and pad edge in this case since the titles can be controlled with offset and it’s unclear what is the standard axis-to-title offset in NDC terms. Similarly, a way to get the actual width and height of the histogram frame excluding the title in NDC terms would be great.

I need this to write some text placement using the DrawLatexNDC methods. Trial and error is clearly not affordable due to sensitivity wrt canvas aspect ratio.


May be the following macro helps to understand ?

    auto c = new TCanvas("c","c");

    c->SetRightMargin(0.25); // right margin is 1/4 of the canvas
    c->SetLeftMargin(0.25);  // left margin is 1/4 of the canvas


   auto *line = new TLine();
   line->DrawLineNDC(.5,0.,.5,1.);   // line in the middle
   line->DrawLineNDC(.75,0.,.75,1.); // line on the right margin
   line->DrawLineNDC(.25,0.,.25,1.); // line on the left margin

Odd. This was exactly my initial try but somehow it didn’t work. But your macro does.

I’ll try to identify what’s different and get back to you.

Ok turned out you are absolutely right, it does line up perfectly. For TLine.

However, I don’t understand then why is the TLatex not drawn at the same point as the line, but instead a bit to the left? MWE as attached, line 201 is where the TLatex drawing happens.


Ok wait it’s just my being silly. It’s because I had the txu.SetTextAlign(23) thing. With 13 it does start at the right position.

However this is clearly not I wanted; the lines were meant to make it so that the text is center-aligned between the primary ticks.

How do I achieve such an effect?

the alignment should be 22 as shown here
and the text position should be the middle of the ticks

Right, that could work.

In the meantime I achieved what I wanted by using TPaveText over TLatex.

Thanks for the assistance.

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