Tlatex location in log scale

hi dear experts,

i am trying to draw latex texts on a graph with the y axis log scale.

the text always appears at the top of the graph and when I try to change its location by mouse it goes at the horizontal axis and stuck there.

i tested different location values but the same thing happened.

TFile* f = new TFile(“result.root”);
TCanvas* c1 = new TCanvas(“c1”, “”);

TH2D* edepPrimaryH = (TH2D*)f->Get(“2d_PrimaryedepKernels”);
TH2D* edepFirstH = (TH2D*)f->Get(“2D_FirstedepKernels”);
TH2D* edepSecondH = (TH2D*)f->Get(“2D_SecondedepKernels”);
TH2D* edepMultipleH = (TH2D*)f->Get(“2D_MultipleedepKernels”);
TH2D* edepeBremAnnihilH = (TH2D*)f->Get(“2D_eBremAnnihiledepKernels”);
TH2D* massH = (TH2D*)f->Get(“2d_Mass”);

double ttreedose;
double ttreepol;
double ttreer;
TTree* _angle1 = new TTree(“Ntuple1”, “Edep”);
_angle1->Branch(“d”, &ttreedose, “d/D”);
_angle1->Branch(“p”, &ttreepol, “p/D”);
_angle1->Branch(“r”, &ttreer, “r/D”);

double no_photon=1e6-3170;
double to_gray=1.6091e-13;
double incident_e=1.25;
double to_centigray=1e2;
double scale=(to_gray

for(Int_t iphi=0;iphi<48;iphi++)
for(Int_t ir=0;ir<25;ir++)
double edep=edepPrimaryH->GetBinContent(iphi,ir)
double dose = edep/massH->GetBinContent(iphi,ir);
TMultiGraph *mg = new TMultiGraph(“mg”, ";r#[]{cm};Dose#timesr^{2}
{} #[]{#frac{^{2}
rr:r",“p==0 && r<20”,"");

TLatex latex;
latex.SetTextAlign(13); //align at top
latex.DrawLatex(5,5,“0^{#circ} - 3.75^{#circ}”);
latex.DrawLatex(5,5,“22.5^{#circ} - 26.25^{#circ}”);
latex.DrawLatex(5,5,“45^{#circ} - 48.75^{#circ}”);

how can i draw them?
many thanks,

Try: latex.DrawLatexNDC(0.5, 0.5, "blah blah");

1 Like

thank you for your reply,

@couet this is works, but if its location is changed by the mouse (when left-click mouse is released) the latext will disappear I don’t know why this is happening i don’t know it depends on the previous lines or something else.

i can set location values and don’t change it location by mouse however for better positioning and angle i prefer to set its location by mouse.

Hi @Keyvan_Tabaei,

Unfortunately, @couet is off this week and might take a while for him to reply.


1 Like

Hi @jalopezg
Thank you for your attention,

I used NDC and set position values.
that was not a crucial problem although it is better to know how we can use Tlatex in log scale while changing its location by mouse is possible.

Seems to me it works fine. See that plot. I placed a text at Y = 500:

Now if I go to log scale on Y, I get this plot and the text is still at Y = 500… thats’s what we want.

1 Like

The problem description says that, when the canvas is using the “log Y” then:

1 Like

I just tried. I do not see that with ROOT master. It works fine for me.

1 Like