TText, SetTextAlign

Dear ROOTers,

I’m having an issue with aligning my text on a canvas. The text I created overlaps with the picture itself, and I’d like to move the text upwards so that both the picture and the text could be seen properly. Currently I’m using t->SetTextAlign(31), and I’ve tried a few other numbers, but those were even worse.

Any ideas how to move the text upwards?
I attached the picture
Thanks!

Try with TText::PaintText or TText::PaintTextNDC

A small example would be allow us to be more helpful to you. Which text class are you using: TText, TLatex, TMathText, TPaveText, …?

You might just want TText::SetX or TText::SetY?

I’m using TText, and this is part of my code:
cdate is a const char.
TText* t = new TText(.5,.5,cdate);
t->SetTextAlign(31);
t->SetTextColor(kBlue);
t->Draw();

I’ll try to use SetX and SetY

Why not just change the position in the constructor?

TText* t = new TText(.5,.1,cdate);
t->SetTextAlign(31);
t->SetTextColor(kBlue);
t->Draw();

Just FYI:

2 Likes

Because I didn’t know that input stood for the position :joy:
Thanks a lot! :slight_smile: and thank you for the advice about formatting my posts

You’re welcome. Here is the brief documentation on the constructor for future reference:
https://root.cern.ch/doc/master/classTText.html#a0cb6bb845e458e61dc2415f5b432bc93

1 Like

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