How to imagine NDC (normalized coord.)

Hey,
im currently try to refine my plots. For instance, i wanna create a TPaveText with text “test” and put it in the upper left corner of my Pad. Since the coordinates used are “NDC”, how do i know in advance, where my text will be printed without trying?

Greetings,
Kevin

these coordinates are a % of the canvas size.

(0.5,0.5) is the middle of the canvas. (1,1) upper right corner, (0,0) bottom left corner.

Thanks for your reply. I know that, but in order to make small adjustment this is not sufficient.

Can you give me an example macro ?

test.cc (312 Bytes)

The Questions is, how can i precisely adapt the coordinates in my constructor that the ouput is displayed in the right manner without trying.

Thanks for you code. It is simple and perfectly ok. But to help you further I need to know what is “the right manner” you are talking about ?

Okay. Lets say i wanna “drag” the Text a little bit more to the left. I could do that with simply trying, but it doesnt seem right :slight_smile: .
I found a temporary solution in which i print my TPad in a position near the desired location. After i plotted my histogram i take advantage of “user coordinates” and realign the position precisely.

Another Question: Can i determine the size of a string in some coord. depending on the text size?

Right now you are not using a Text but a TPaveText which is a box containing text. Pure text is done with TText or TLatex. You can have a look at the reference guide for these two classes to see how they work and yes they have methods returning the text size. You will find them in the doc.

Now using TPaveText is fine also. You can place the box containing the text where you want, either in user coordinates or NDC coordinate. To place it a bit more left you simply change the box coordinates . Using NDC coordinates (option NDC, you use it already in your example) is quite convenient when you want to place the box always at the same position independently of the user coordinates of your plot.

I do not understand why you need to do all this “gymnastic” with TPad to place the TPaveText… I guess I am missing something …

Thats the crucial point. It doesnt matter now because i changed my workflow. At first i thought i would be good practice to loop over my TTree and set the style at the same time. I guess that is not the right manner so i will shift my style setting in a separate file and now it is no problem to call my method twice to realign the textbox.
I appreciate your help.

I still do not understand why you need two steps. But you solved your problem that’s t fine.

Is there a way to get the size of a Legend entry (text+marker) in NDC?
And how can i adjust the number of divisions in the y axis in the lower pad in a ratioplot? Sth like
ratio->GetLowerRefGraph()->GetYaxis()->SetNdivisions(505) doesnt work. I cant even change it in the graphics editor.

I hope it is fine to post other questions here instead of opening a new topic respectively.
Thanks in advance.
Kevin

No it is not … But I will answer anyway

No, not directly

And how can i adjust the number of divisions in the y axis in the lower pad in a ratioplot? Sth like
ratio->GetLowerRefGraph()->GetYaxis()->SetNdivisions(505) doesnt work. I cant even change it in the graphics editor.

Yes you are right I cannot either. I have to check…

Reading the TRatioPlot doc I found the answer about the low Y Axis number of divisions:

   ratio->GetLowYaxis()->SetNdivisions(505);

I appreciate it. Your suggestion works totally fine. Thank you very much.

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