Consider this example:
TCanvas * c = new TCanvas;
TH1 * h = new TH1F("h", "h", 5, 0.0, 5.0);
h -> Draw();
TPaveText * pt = new TPaveText(0.1, 0.1, 2.8, 0.3);
pt -> AddText("text");
pt -> SetTextAngle(45);
pt -> Draw();
The output is
The text is horizontal even though I have set the angle at 45 deg. What is wrong?
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
See the first example of the documentation.
Remove pt -> SetTextAngle(45);
and after drawing, add:
TText *t2 = pt->GetLineWith("text");
t2->SetTextAngle(45);
and you may need to also add c->Modified();
to update the canvas.
What would be the corresponding option for TLatex
?
How can I centre TLatex on a specific point?
At https://root.cern/doc/master/classTLatex.html I see no examples of text direction being changed, nor any option how I could retrieve text from TLatex
couet
6
To understand better what are the possible options to orient a TLatex
- open an empty canvas
- go in View->Toolbar
- create a TLatex clicking on “L”
- position/ move/resize/ center the text
- save the canvas as a .C and look at the code generated.
I find there are many things unclear:
What is the meaning of the trailing “<
” after gdfg
?
I don’t know how to write #frac{a}{b}
- pressing {
generates an error
*ERROR<TLatex>: Error in syntax of "#frac"
==> #frac{
Where are the functions to position/ move/resize/ center the text?
couet
8
{
TCanvas *c1 = new TCanvas("c1", "c1",10,45,700,527);
TLatex * tex = new TLatex(0.5,0.5,"Hello");
tex->SetTextSize(0.15);
tex->SetTextAngle(25.);
tex->Draw();
}
system
Closed
9
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.