That code works well for me (supposing your hist exists and is drawn). One thing: remove myLatex.Draw(“SAME”), as “same” doesn’t exist for TLatex, and you already did DrawLatex anyway.
Try adding
C1.Modified()
C1.Update()
before saving the canvas (although in my case it works without these lines). Maybe also try gPad.Modified() and gPad.Update() instead.
Thanks a lot for your response, and thanks for telling me that the myLatex.Draw(“SAME”) is unnecessary! Unfortunately, none of those seem to do the trick. It’s very strange, code equivalent to this works in other places in the same script. I guess there is always the option of making a script just to draw this one canvas.
What if you only have these lines (plus opening the file and getting the histogram)? Do you still not get the text? If it works, start adding the rest of the code by parts and see where it fails. Or post all the related code.
{
auto C1 = new TCanvas();
auto hist = new TH1F("h","h",10, -100,0);
hist->SetMaximum(3.14159);
hist->SetMinimum(-3.14159);
hist->Draw();
auto myLatex = new TLatex();
myLatex->DrawLatexNDC(0.2, 0.4, "Some text here");
}